Worksheet_Change

M

MLT

I have the following generic code to spot when a cell is changed in a
single worksheet:

Private Sub Worksheet_Change(ByVal Target As Range)
Msgbox Target.Address
End Sub

Is there such thing as a sort of "Workbook_Change" so that any cell in
any sheet of the workbook will still trigger the msgbox?
 
D

Dave Peterson

There's a Workbook_SheetChange that belongs under the ThisWorkbook module.

You may want to use:
Msgbox Target.Address(external:=true)
or
Msgbox Target.Address & vblf & sh.name
 
O

OssieMac

Yes. In the VBA editor on the left side is the project explorer. Double click
ThisWorkbook and insert the following code. Note it returns both sheet an an
object and the range.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

MsgBox Sh.Name & " " & Target.Address

End Sub

Note that at the top of the VBA editor where you place the code there are 2
drop down boxes. For whatever module you are in, you click the left one then
you can select the object for which you want code and then clicking the
dropdown on the right will display all of the events. Clicking one of the
events creates the Private Sub .... End Sub for the particular event.
 

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