Pergunta

I'm trying to add a Cell to an existing Name via VB.

My best Attempt looks like this:

Tabelle1.Names("delCase").RefersTo = Tabelle1.Names("delCase").RefersTo + ";" + Target.Address

But this prompts a

Application- or objectdefined Error

Foi útil?

Solução

Try this (TRIED AND TESTED)

Union(Tabelle1.Range("delCase"), Target).Name = "delCase"

Outras dicas

Instead of trying to assign a string to RefersTo, you can directly assign a Range (as RefersTo is of type variant). Changing your line slightly to:

Tabelle1.Names("delCase").RefersTo = Tabelle1.Range("delCase;" & Target.Address)

Then works as expected.

If you'd like a more elegant way to do this, try:

Tabelle1.Range("delCase;" & Target.Address).Name = "delCase"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top