Macro

Copper Contributor

Hi, 

 

So i have created a macro in my excel sheet, and I was wondering if it is possible to have the macro be automatic every time the certain cell is equal to my specification, rather than me having to manually do it every time. 

Does anyone know if this is possible?

1 Reply

You should use the worksheet change event on the worksheet that your cell is. this event has a Target variable that is the address of the cell that is changed. so you can write an IF statement within your change event to check the address of the cell and if the address is the same with your cell, call the macro. 

 

Private Sub Worksheet_Change(ByVal Target As Range)

 

     if target.address="$A$2" then call MyMacroName 'this is the name of the public sub that is in your macro module

 

end sub