+ Reply to Thread
Results 1 to 2 of 2

Workbook Event

  1. #1
    Registered User
    Join Date
    02-26-2006
    Posts
    1

    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!

  2. #2
    JE McGimpsey
    Guest

    Re: 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 <[email protected]>,
    pusky123 <[email protected]>
    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1