MsgBox prompt
Results 1 to 4 of 4

Thread: MsgBox prompt
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Dec 2016
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default MsgBox prompt

    Hi,

    I am looking to add a MsgBox with Yes/No prompt, below is how far i have got.

    Answer = MsgBox("Have you set Bla Bla to Active?", vbYesNo)
    If Answer = vbYes Then


    Else If Answer = vbNo Then


    Basically what i am looking to achieve is, If yes is clicked, the file saves.
    If no is clicked, well then its back to work you go.

    Appreciate any help i get, Thanks.

  2. #2
    Board Regular
    Join Date
    Mar 2015
    Posts
    249
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MsgBox prompt

    Code:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    Answer = MsgBox("Have you set Bla Bla to Active?", vbYesNo)
    
    If Answer = vbNo Then
        MsgBox "Set Bla Bla to active before you save"
        Cancel = True
    End If
    
    End Sub
    Last edited by seguin85; Dec 12th, 2016 at 11:03 AM.

  3. #3
    Board Regular
    Join Date
    Jul 2012
    Location
    Hampshire, UK
    Posts
    4,983
    Post Thanks / Like
    Mentioned
    23 Post(s)
    Tagged
    1 Thread(s)

    Default Re: MsgBox prompt

    another way of writing the code:

    Code:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    
      Cancel = MsgBox("Have you set Bla Bla to Active?", vbYesNo) = vbNo
    
    
    End Sub
    Code should be placed in the Thisworkbook code page.


    Dave

  4. #4
    New Member
    Join Date
    Dec 2016
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: MsgBox prompt

    thanks a lot, they both worked

Some videos you may like

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
  •