Question

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

Was it helpful?

Solution

Try this (TRIED AND TESTED)

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

OTHER TIPS

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top