Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook Open event Libby Excel Programming 1 November 29th 04 04:10 PM
Workbook open event G Lam Excel Programming 3 November 12th 04 04:38 PM
Workbook Open event Todd Huttenstine Excel Programming 1 April 21st 04 07:06 PM
Workbook Deactivate Event TerryF[_2_] Excel Programming 1 January 6th 04 01:16 AM
Workbook Open Event Dave Peterson[_3_] Excel Programming 0 October 17th 03 02:38 AM


All times are GMT +1. The time now is 11:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"