Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do you make a macro run automatically when a criteria is met?
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do you make a macro run automatically when a criteria is met?
Hi Tom,
I'm just a beginner in this stuff why don't use smple way like : Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target = "My word" Then My Macro End Sub Just asking ... Thanks, Halim Tom Ogilvy wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
how do you make a macro run automatically when a criteria is m
SelectionChange fires when the cell is selected. If the user entered My
word, the macro would not be fired until the user reselected the cell. Then, after it had fired, it would fire again each time the user selected the cell (and its value remained My word) and it would fire everytime the user selected any cell that contained My word. If the user selected several cells your code would raise a type mismatch error. So the smple way you suggested doesn't answer the requested functionality and is flawed. -- Regards, Tom Ogilvy "halim" wrote: Hi Tom, I'm just a beginner in this stuff why don't use smple way like : Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target = "My word" Then My Macro End Sub Just asking ... Thanks, Halim Tom Ogilvy wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can make a macro to run evey one hour-automatically | Excel Discussion (Misc queries) | |||
How do I make a section sort automatically? | Excel Discussion (Misc queries) | |||
How do I make a macro automatically select Yes when a yes/no box appears? | Excel Programming | |||
How to make a macro that automatically starts after clicking a cel | Excel Programming | |||
Make a macro run automatically in Excel 03??? | Excel Programming |