ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro run from If Then function (https://www.excelbanter.com/excel-programming/354939-macro-run-if-then-function.html)

Nikki

Macro run from If Then function
 
The goal is to run 'MacroX' if cell equals Y. Is that even possible?

Rick Hansen

Macro run from If Then function
 

"Nikki" wrote in message
...
The goal is to run 'MacroX' if cell equals Y. Is that even possible?




Rick Hansen

Macro run from If Then function
 
HI Nikki,
Add the following code the to Worksheet_Change() event on the worksheet
where the cell is located.

hth, Rick


Private Sub Worksheet_Change(ByVal Target as Range)
If Target.address = "$C$4" and Target.Value = "Y" Then ' <<
Change cell address
Call MacroX
End If
End Sub




"Nikki" wrote in message
...
The goal is to run 'MacroX' if cell equals Y. Is that even possible




Lonnie M.

Macro run from If Then function
 
Hi, yes it is possible. Place this in the sheet module for the
worksheet you want to check for 'Y' value:

Private Sub Worksheet_Change(ByVal Target as Range)
'Test to see if change ocurred in Cell 'B2'
If Target.address(0,0) < "B2" Then exit sub
'Test if Cell B2 = "Y"
If Target.value = "Y" Then Call MacroX
End Sub

HTH-Lonnie M.



All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com