PDA

View Full Version : Solved: Listening to the active sheet's events from the personal macro



someboddy
07-19-2010, 10:31 AM
I have a form in my personal macro workbook, and I want it to update itself when I navigate around the cells in my workbooks. How can I make it run a subroutine every time a selection change event is lunched in any workbook while the form is loaded?

Bob Phillips
07-19-2010, 10:47 AM
Use application events.



Public WithEvents App As Application

Private Sub App_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
MsgBox Target.Address
End Sub

Private Sub Workbook_Open()
Set App = Application
End Sub


This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code

someboddy
07-19-2010, 11:36 AM
Thanks! That was just what I needed!