Run Macro on Change in Worksheet

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hello,
I would like to run a macro when a change is made in a given column on a
worksheet (such as column B). I know I need to use:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

end sub

Not sure how this works though.

Thanks for your help.

Bill
 
Bill,

First test if the column is selected
If Target.Column = 2 Then

and then call your macro
myMacro

end the If statement
EndIf

The only other thing to say is that this code goes in the sheet module of
the sheet in question (right-click on the sheet tab, select View Code from
the menu, and put the code in there. Your macro should be in a normal code
module, and be a public sub.
 
Back
Top