Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The best answer would depend on how A1 gets to be less than 5
If it is by someone editing the cell, then use the change event. If it is by calculation or from a DDE link, then use the Calculate event See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm If using the calculate event, you would also need to consider what happens after the cell first achieves the tested condition and the macro is run once for that event. -- Regards, Tom Ogilvy "RK" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Autorun macro | Excel Discussion (Misc queries) | |||
AutoRun Macro | Excel Worksheet Functions | |||
autorun a macro | New Users to Excel | |||
Autorun macro | Excel Worksheet Functions | |||
autorun a macro | Excel Programming |