ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook Event (https://www.excelbanter.com/excel-programming/354428-workbook-event.html)

pusky123

Workbook Event
 

Hi,

I want a message box to appear when the value of a cell reaches a
certain level.

I've tried the following code in the 'ThisWorkbook' section but it just
comes up with an error:

Private Sub Workbook_SheetCalculate(ByVal_Sh As Object)
If Sh.Range("B21").Value 0 Then
MsgBox "No Lose Scenario " & Sh.Name
End If
End Sub


The error that is dispalyed is 'Procedure Declaration does not match
description or event of procedure having the same name'. It then
highlights the first line.

Could anyone help please? Please note I am an absolute beginner!


--
pusky123
------------------------------------------------------------------------
pusky123's Profile: http://www.excelforum.com/member.php...o&userid=31947
View this thread: http://www.excelforum.com/showthread...hreadid=516683


JE McGimpsey

Workbook Event
 
Change the first line to

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)


The default argument name is "Sh", not "ByVal_Sh"

"ByVal" indicates that it should be passed by value, not reference (see
VBA Help's "Sub Statement" topic for an explanation)



In article ,
pusky123
wrote:

Hi,

I want a message box to appear when the value of a cell reaches a
certain level.

I've tried the following code in the 'ThisWorkbook' section but it just
comes up with an error:

Private Sub Workbook_SheetCalculate(ByVal_Sh As Object)
If Sh.Range("B21").Value 0 Then
MsgBox "No Lose Scenario " & Sh.Name
End If
End Sub


The error that is dispalyed is 'Procedure Declaration does not match
description or event of procedure having the same name'. It then
highlights the first line.

Could anyone help please? Please note I am an absolute beginner!



All times are GMT +1. The time now is 12:05 PM.

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