Thread: Run macro if
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Run macro if

This goes in the sheet code module for the shee with J20=E2.

Private Sub Worksheet_Change(ByVal Targer As Range)
IF Target = Range("J20") Or Target = Range("E2") Then
If Range("J20") = Range("E2") Then
Call 'myMacro
End If
End If
End Sub

When changes are made to either J20 or E2 the procedure will call the macro.
You will need to substitute the actual macro name where 'myMacro appears in
the code above.




"Kashyap" wrote:

Hi,

I have assigned a macro to an object and I need that object to act as button
only when J20=E2.

i.e; I should be able to run that macro only if J20=E2.