Running a macro from an IF function

  • Thread starter Thread starter Gordon Forbes
  • Start date Start date
G

Gordon Forbes

I want to run a macro from an IF Function if a cell ="no"
or do nothing if the cell is not "No". For example

IF(A1="No",run my macro,"")

Is this possible or is there any other way I can get the
macro to run if the cell = "No"

Thanks
Gordon
 
You can't run from a formula but you can make a formula run a worksheet
change event to run your macro.
right click on sheet tab>copy/paste this>SAVE

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And ucase(Target) = "NO" Then runmymacro
End Sub

Sub runmymacro()
[b10] = 2
End Sub
 
That worked fine Don, thanks very much.

Cheers
Gordon

-----Original Message-----
You can't run from a formula but you can make a formula run a worksheet
change event to run your macro.
right click on sheet tab>copy/paste this>SAVE

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And ucase(Target) = "NO" Then runmymacro
End Sub

Sub runmymacro()
[b10] = 2
End Sub
--
Don Guillett
SalesAid Software
(e-mail address removed)
Gordon Forbes said:
I want to run a macro from an IF Function if a cell ="no"
or do nothing if the cell is not "No". For example

IF(A1="No",run my macro,"")

Is this possible or is there any other way I can get the
macro to run if the cell = "No"

Thanks
Gordon


.
 
glad to help

--
Don Guillett
SalesAid Software
(e-mail address removed)
That worked fine Don, thanks very much.

Cheers
Gordon

-----Original Message-----
You can't run from a formula but you can make a formula run a worksheet
change event to run your macro.
right click on sheet tab>copy/paste this>SAVE

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And ucase(Target) = "NO" Then runmymacro
End Sub

Sub runmymacro()
[b10] = 2
End Sub
--
Don Guillett
SalesAid Software
(e-mail address removed)
Gordon Forbes said:
I want to run a macro from an IF Function if a cell ="no"
or do nothing if the cell is not "No". For example

IF(A1="No",run my macro,"")

Is this possible or is there any other way I can get the
macro to run if the cell = "No"

Thanks
Gordon


.
 
Back
Top