Running A Macro when data is updated.

J

joecrabtree

To all,

I have a macro in a worksheet that I want to run when any data in
Column B changes. At the moment it is run by a button click. Is there
anyway to do this without rewriting the macro?

Thanks in advance,

Joseph Crabtree
 
P

paul.robinson

Hi
Put the code inside the Change or selection_Change events of your
sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
'code
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'code
End Sub

To access these, click on the sheet tab in the VBE. Change the left
hand dropdown from General to Worksheet, and choose your event sub in
the right hand sheet. Highlight the sub name and click F1 to see some
examples, as it can be subtle (e.g you don't want the change to trigger
the change etc into an infinite loop).
regards
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top