View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default how do you make a macro run automatically when a criteria is met?

you could use the change event.

Right click on the sheet tab, select view code and paste in code like this
(adjusted for your actuall cell/word/macro to run)

Private Sub Worksheet_Change(ByVal Target As Range)
Static bFlag As Boolean
If Target.Count 1 Then Exit Sub
If Target.Address = "$B$9" Then
If Target.Value = "Goofy" Then
If Not bFlag Then
mymacro
bFlag = True
End If
Else
bFlag = False
End If
End If
End Sub

Chip Pearson's page on events:
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy



"Lee Crew" wrote:

I am trying to set up a marco that is run automatically if a certian word is
put into a certian cell in a workbook is this possible?

Many thanks
Lee