Does anyone know of a way to do run a macro based on a cell value. EG i
cell A1 = 0, dont run macro - otherwise run macro.
below macro will run your code is cell a1 is anything but 0.
Do you want the macro to run automatically if a different value i
inputted into cell a1, or are you happy for the user to run the macr
manually? (if automatically, more code is required)
When should A1 be evaluated? When an entry is made? When a calculation
is performed? Every 10 seconds?
If when an entry is made in A1, put something like this in your
worksheet code module (right-click the worksheet tab and choose View
Code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If .Address(False, False) = "A1" Then
If IsNumeric(.Value) Then If .Value <> 0 Then MyMacro
End With
End Sub
where MyMacro is the name of your macro.
If when a calculation is performed, put something like this in the
worksheet code module instead:
Private Sub Worksheet_Calculate()
With Range("A1")
If IsNumeric(.Value) Then If .Value <> 0 Then MyMacro
End With
End Sub