ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically run macro on sheet change (https://www.excelbanter.com/excel-programming/332182-automatically-run-macro-sheet-change.html)

steven

Automatically run macro on sheet change
 
Is there a way to put a macro or vb code on a Sheet's code that will
automatically run when there is a change in the sheet. I tried to put code
by itself but it gave me an error message saying "Invalid Outside Procedure".

Thanks for your help.


dominicb[_32_]

Automatically run macro on sheet change
 

Good evening Steven

When you say "a change in the sheet" do you mean when the sheet is
changed or when the user changes sheets? If the former, which I
suspect, try this, inserted in the relevant sheet's code section.

Private Sub Worksheet_Change(ByVal Target As Range)

' Your code can go in here

End Sub

Your macro would then trigger every time that particular sheet is
changed.

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=380252



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

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