ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Event Macro Calculate Does Not Work (https://www.excelbanter.com/excel-programming/337469-event-macro-calculate-does-not-work.html)

Carl Bowman

Event Macro Calculate Does Not Work
 
I need a macro to run the application "EnterTitle" any time the workbook is
recalculated, whether it be manually using F9, or automatically, when any
cell changes if the calculation mode is in automatic. I entered the following
syntax by right-clicking the Excel logo and selecting "View Code" but this
does not work.

Sub Workbook_Calculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Thanks in advance.

Rowan[_2_]

Event Macro Calculate Does Not Work
 
Try

Sub Workbook_SheetCalculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Hope this helps
Rowan

"Carl Bowman" wrote:

I need a macro to run the application "EnterTitle" any time the workbook is
recalculated, whether it be manually using F9, or automatically, when any
cell changes if the calculation mode is in automatic. I entered the following
syntax by right-clicking the Excel logo and selecting "View Code" but this
does not work.

Sub Workbook_Calculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Thanks in advance.


Dave Peterson

Event Macro Calculate Does Not Work
 
Next time you're in the VBE, click on ThisWorkbook (or do the same rightclick on
the excel logo and select view code).

On the right hand side window above the code window, you'll see two dropdown
boxes.

Choose Workbook from the left hand side box.

Now look through the list of events inside that right hand side dropdown.

You won't see a workbook_calculate event. But you will see this:

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

You can't make up your own events. But you can tie into the correct one <bg.

Option Explicit
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

But if "entertitle" is in that same project, you can just call it:

Option Explicit
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Call EnterTitle
'or even
EnterTitle
'but not both!
End Sub

Carl Bowman wrote:

I need a macro to run the application "EnterTitle" any time the workbook is
recalculated, whether it be manually using F9, or automatically, when any
cell changes if the calculation mode is in automatic. I entered the following
syntax by right-clicking the Excel logo and selecting "View Code" but this
does not work.

Sub Workbook_Calculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Thanks in advance.


--

Dave Peterson

Norman Jones

Event Macro Calculate Does Not Work
 
Hi Carl,

Sub Workbook_Calculate(ByVal Sh As Object)


I am not aware of this event.

The following worked for me:

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub


---
Regards,
Norman



"Carl Bowman" wrote in message
...
I need a macro to run the application "EnterTitle" any time the workbook is
recalculated, whether it be manually using F9, or automatically, when any
cell changes if the calculation mode is in automatic. I entered the
following
syntax by right-clicking the Excel logo and selecting "View Code" but this
does not work.

Sub Workbook_Calculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Thanks in advance.




Carl Bowman

Event Macro Calculate Does Not Work
 
That worked! Thanks!

"Rowan" wrote:

Try

Sub Workbook_SheetCalculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Hope this helps
Rowan

"Carl Bowman" wrote:

I need a macro to run the application "EnterTitle" any time the workbook is
recalculated, whether it be manually using F9, or automatically, when any
cell changes if the calculation mode is in automatic. I entered the following
syntax by right-clicking the Excel logo and selecting "View Code" but this
does not work.

Sub Workbook_Calculate(ByVal Sh As Object)
Application.Run "EnterTitle"
End Sub

Thanks in advance.



All times are GMT +1. The time now is 02:10 PM.

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