ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running A Macro when data is updated. (https://www.excelbanter.com/excel-programming/378679-running-macro-when-data-updated.html)

joecrabtree

Running A Macro when data is updated.
 
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


[email protected]

Running A Macro when data is updated.
 
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


joecrabtree wrote:

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




All times are GMT +1. The time now is 10:21 AM.

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