Execute excel macro based upon cell condition

R

RKGriffin

There must be a simple answer to this, but I haven't been able to figure it
out.
How can I run a macro based upon a cell's condition. For example: Run a
specific macro when cell A1=1. I would really appreciate help with this
question. I'm trying to enhance a workbook that I use to teach students.

Thank you!

Robert K. Griffin
UMass Prof
 
J

JulieD

Hi

formulas can't be used to initiate macros, however you can use a
worksheet_change event which when anything happens on the sheet, checks to
see if the condition has been met and then will run the code.

to use a worksheet_change event, right mouse click on the sheet tab where
you are going to check the value of A1, choose view / code
on the right hand side of the screen type

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" And Range("A1") = 1 Then
Call testloop 'put the name of your macro in here
End If

End Sub

Cheers
JulieD
 
Top