문제

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

도움이 되었습니까?

해결책

Try this (TRIED AND TESTED)

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

다른 팁

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"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top