View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Run Macro based on IF

As previously written it would fire on any change. Use this way if only a1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$A$1" Then Exit Sub
If Target < Range("b1") Then Call mymacro
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
You would use a worksheet change if you are changing a1 or b1


Private Sub Worksheet_Change(ByVal Target As Range)
If Target < Range("b1") Then Call mymacro
'if? you really want to fire with ANY change use
'If Range("a1") < Range("b1") Then Call mymacro
End Sub

Sub mymacro()
MsgBox "hi"
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Nikki" wrote in message
...
I want to run a macro if cell a1 does not equal b1.
Private Sub Worksheet_Change(ByVal Target As Range)
If (a1 < b1) Then
Macro1
End If

End Sub

When I use an equal sign the macro runs every time and when I use the not
equal it won't run at all.
Thanks for the help!
--
Thanks,
Nikki