ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run macro problem (https://www.excelbanter.com/excel-programming/327144-run-macro-problem.html)

gareth

Run macro problem
 
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


JE McGimpsey

Run macro problem
 
Something like this?

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


In article ,
"Gareth" wrote:

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



All times are GMT +1. The time now is 03:44 AM.

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