+ Reply to Thread
Results 1 to 3 of 3

Trigger Event Code

  1. #1
    Shawn
    Guest

    Trigger Event Code

    I have a formula in cell B1 that is linked to several other cells. If
    various condidtions are met, the value in cell B1 will equal, "Yes".
    Otherwise, it equals, "No".

    Is there a way I can trigger a macro anytime the value in Cell B1 changes
    from "No" to "Yes". I would like for a message box to pop-up with a warning.



    --
    Thanks
    Shawn

  2. #2
    Registered User
    Join Date
    06-30-2005
    Posts
    61
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    If Target.Address = "$B$1" Then
    Application.EnableEvents = False
    If Target.Value = yes Then
    Msgbox ("B1 = Yes")
    Application.EnableEvents = True
    End If

  3. #3
    Norman Jones
    Guest

    Re: Trigger Event Code

    Hi Shawn,

    Try:
    Private Sub Worksheet_Calculate()
    Dim rng As Range
    Static blFlag As Boolean
    Set rng = Range("B1")

    If rng.Value = "Yes" Then
    If Not blFlag Then
    MsgBox "No has changed to Yes", _
    vbInformation, "ALERT!"
    blFlag = True
    End If
    Else
    blFlag = False
    End If

    End Sub


    This is worksheet event code and needs to be placed in the sheet module
    behind the worksheet in question, *not* in a standard module.

    So, access the sheet module by right-clicking the sheet tab, select 'View
    Code', paste the above code, Alt-F11 to return to the worksheet.


    ---
    Regards,
    Norman



    "Shawn" <[email protected]> wrote in message
    news:[email protected]...
    >I have a formula in cell B1 that is linked to several other cells. If
    > various condidtions are met, the value in cell B1 will equal, "Yes".
    > Otherwise, it equals, "No".
    >
    > Is there a way I can trigger a macro anytime the value in Cell B1 changes
    > from "No" to "Yes". I would like for a message box to pop-up with a
    > warning.
    >
    >
    >
    > --
    > Thanks
    > Shawn




+ 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