ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   triggering macros (https://www.excelbanter.com/excel-programming/340372-triggering-macros.html)

gvm

triggering macros
 
I have two macros. I need one to run each time the spreadsheet finishes
recalculation. I need the other one to run each time a particular cell is
changed and I need the spreadsheet to recalculate once it has finished. How
do I do these please?
thanks
Greg

JMB

triggering macros
 
right click on your sheet tab, select view code and use the following event
handlers


Private Sub Worksheet_Calculate()
'Do Something
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
'Do Something
End If
End Sub

Of course, you will need to change the above cell address from $A$1 to
whatever you need.

If your calculation is set to automatic, it should not necessary to
recalculate the worksheet after the Worksheet_Change event (and I believe the
worksheet will recalculate before the Workhseet_Change event fires). If you
need to recalculate, you can use Target.Parent.Calculate or
Application.CalculateFull (to recalculate the entire workbook).




"gvm" wrote:

I have two macros. I need one to run each time the spreadsheet finishes
recalculation. I need the other one to run each time a particular cell is
changed and I need the spreadsheet to recalculate once it has finished. How
do I do these please?
thanks
Greg



All times are GMT +1. The time now is 08:49 AM.

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