Change event triggered by a named range

S

Sean

Hi,

I have a event on a worksheet that is triggered when cell $A$5 is
changed. The problem is when cells are inserted or deleted from the
sheet then I need to update my macro.

Is there a way to target a named range?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$5" Then
MsgBox "Hello"
End If
End Sub

Works

but

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "range name" Then
MsgBox "Hello"
End If
End Sub

Does not.

Any assistance will be appreciated.

Regards.

Sean
 
N

Norman Jones

Hi Sean,

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("Test")) Is Nothing Then
MsgBox "Hello"
End If
End Sub

Replace Test withyour range name.
 
G

Guest

Hi,
you may be able to overcome something like insertion of rows by naming the
range, but i am not sure if this addresses your question.
 
K

Kaak

In the new version of Visual Studio 2005
There are tools for developing office applications.
You can write code that will target the on change event of a name
range.

There is only a beta version available of VSTO
And you have to write it in VB.net or C#.net.

If you want to know more about this option let me kno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top