Macro triggered when Data is changed and worksheet is deselected

  • Thread starter Thread starter Hari
  • Start date Start date
H

Hari

Hi,

I have a worksheet by the name "Raw Data".

I want that if data in this worksheet is modified in any cell ( please note
data only, not formats etc..) then if the user selects any other worksheet
after changing data in "Raw Data" then a macro by the name Macro 1 should
run.

That is I want the macro to run only if the data is changed and ALSO only
when the user leaves the particular worksheet. If s/he is working on "Raw
Data" and switches to another workbook and switches back to worksheet "Raw
Data" then the macro shouldnt run (Because user will be copying data between
from other workbooks to the worksheet Raw Data.)

Please guide me for the code(syntax) and where I should put/stick this code.

Regards,
Hari
India
 
Rightclick on that worksheet's tab and select view code.

Use the dropdowns on the top of the right hand window to choose:
Worksheet
and
Deactivate

You should see something like:

Option Explicit
Private Sub Worksheet_Deactivate()

End Sub

And if you want to learn more about what events are:

Chip Pearson has some notes about events at:
http://www.cpearson.com/excel/events.htm

David McRitchie also has notes at:
http://www.mvps.org/dmcritchie/excel/event.htm

Chip has a note near the bottom of his page where you can download EventSeq.xls
to see what runs when.
 

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

Back
Top