Run macro problem

  • Thread starter Thread starter Gareth
  • Start date Start date
G

Gareth

I want to call a macro from the Worksheet Deactivate
event, my problem is that I want the macro to carry out
calculations on the active sheet. Is there any way to
include anything in the Deactivate event that will switch
back to the previously active sheet and run the macro.

For example:
Sheet1 is active and I click on Sheet2 which contains a
summary of data on Sheet1, the macro needs to run so that
the data on Sheet2 is updated (macro cannot be run from
the activate event of sheet2).

Thanks in advance.

Gareth
 
Something like this?

Private Sub Worksheet_Deactivate()
With ActiveSheet
.Range("J11").Value = Application.Sum(.Range("A1:J10"))
End With
End Sub
 

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