Worksheet_Change macro not working

0

I have a macro set up so that when a cell changes a macro is called. It works perfectly fine when the target address is a cell reference.

Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$2" Then
        Call MyMacro
    End If
End Sub

However if I change the address to a name reference, it stops working.

Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "z_Goto" Then
        Call MyMacro
    End If
End Sub

Am I missing something? Thanks.

Answer
Discuss

Answers

0
Selected Answer

Try this:

Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = Range("z_Goto").Address Then
        Call MyMacro
    End If
End Sub

Changed "z_Goto" to Range("z_Goto").Address

That should do the trick!

Discuss

Discussion

That worked perfectly. Thank you very much!

I had tried using "Range", might've tried using "Address" at one point too. Never thought to use them together. Hahaha.
Cathy (rep: 2) Sep 26, '18 at 4:40 pm
I feel your pain on so many levels!!!! Programming can be more like hair-pulling in the end haha. If you need anything else, we're here :)
don (rep: 1482) Sep 27, '18 at 1:21 am
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login