Thread: Autorun Macro
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Autorun Macro

Hi
you can use the worksheet_change event. Put the following in your
worksheet module:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
With Target
If .Value < 5 Then
Application.EnableEvents = False
' insert your code
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub


--
Regards
Frank Kabel
Frankfurt, Germany

RK wrote:
How do I get a macro to auto run (not on starting excel, but at any
time).

Say whenever the value in cell A1<5, automatically Call Macro1