Occurrence
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Occurrence

  1. #1
    Guest

    Default

     
    I have a worksheet setup and when I add data to the A column, I would like a MsgBox to ask, "Is This An Occurrence?" with YesNo buttons. If the answer is yes, I want to add 1 to the B column, If the answer is no, I don't want it to add anything. Can someone tell me how to write this? I can't get the function to occure without manually running it, and I can get it to enter a 1 in the B column but it does it even when I answer NO!

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Guderup, Denmark
    Posts
    288
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Put this code in the code for the sheet that you are using (not the module):
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Msg, Style, Response
    Msg = "Is this an occurfence?"
    Style = vbYesNo + vbCritical + vbDefaultButton2
    Response = MsgBox(Msg, Style)
    If Response = vbYes Then
    Range("b1") = Range("b1") + 1
    End If
    End Sub

    This code will display a box asking if this "Is an occurrence?" If yes is clicked it will add 1 to the value in cell B1. If no is clicked it will not do anything. The code is activated ANY TIME something on the worksheet changes.

    I hope this helps.
    Kind regards, Al

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com