Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49892

Worksheet_Change

$
0
0
How do I get this running twice on a single sheet? This targets A1 to perform this function, but I also want the function to be performed if B1 is changed.

Code:

Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range
    Set KeyCells = Range("A1")
If Range("AA1").Value = "1" Then
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
          Is Nothing Then
            MsgBox "This is 1"
End If
End If
If Range("AA1").Value = "2" Then
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
          Is Nothing Then
            MsgBox "This is 2"
End If
End If
End Sub

P.S. Obviously not that exact code - because a message box saying This is 1 would be ridiculous, I'm just trying to get this working before I build the rest of the code.

Viewing all articles
Browse latest Browse all 49892

Trending Articles