Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 10 of 10

Thread: Re: Add a Confirmation Message Box to a macro?

  1. #1
    New Member
    Join Date
    Feb 2015
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Re: Add a Confirmation Message Box to a macro?

    I have this code that prints everything from data validation, but I also want to run a massage that says "are you sure you want to continue" before running the code. My code works separately but not with the massage code.

    Code:
    Sub ClearINV()
    
    
    Answer = MsgBox("Are you sure you want to continue?", vbYesNoCancel + vbInformation, "Application Message")
    
    
    
    
    
    
    If Answer = vbYes Then Else Exit Sub
    
    
    If Answer = vbYes Then Else Exit Sub
     Sub Iterate_Through_data_Validation()
        Dim xRg As Range
        Dim xCell As Range
        Dim xRgVList As Range
        Set xRg = Worksheets("Lease Abstract").Range("I2")
        Set xRgVList = Evaluate(xRg.Validation.Formula1)
        For Each xCell In xRgVList
            xRg = xCell.Value
            ActiveSheet.PrintOut
        Next
    End Sub
    End If
    End Sub
    Last edited by Fluff; Aug 23rd, 2018 at 03:10 PM. Reason: Code tags

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    13,513
    Post Thanks / Like
    Mentioned
    249 Post(s)
    Tagged
    17 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    Hi & welcome to MrExcel
    How about
    Code:
    Sub ClearINV()
    
    
    If MsgBox("Are you sure you want to continue?", vbYesNoCancel + vbInformation, "Application Message") = vbYes Then
        Dim xRg As Range
        Dim xCell As Range
        Dim xRgVList As Range
        Set xRg = Worksheets("Lease Abstract").Range("I2")
        Set xRgVList = Evaluate(xRg.Validation.Formula1)
        For Each xCell In xRgVList
            xRg = xCell.Value
            ActiveSheet.PrintOut
        Next
    End If
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  3. #3
    New Member
    Join Date
    Feb 2015
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    Thanks a lot for the answer I am very new to VBA

    When I debug it works, but when I run the actual macro it syas "Can not run macro "the file name and macro name". The macro may not be available in this workbook or all macros may be disabled.


    Quote Originally Posted by Fluff View Post
    Hi & welcome to MrExcel
    How about
    Code:
    Sub ClearINV()
    
    
    If MsgBox("Are you sure you want to continue?", vbYesNoCancel + vbInformation, "Application Message") = vbYes Then
        Dim xRg As Range
        Dim xCell As Range
        Dim xRgVList As Range
        Set xRg = Worksheets("Lease Abstract").Range("I2")
        Set xRgVList = Evaluate(xRg.Validation.Formula1)
        For Each xCell In xRgVList
            xRg = xCell.Value
            ActiveSheet.PrintOut
        Next
    End If
    End Sub

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    13,513
    Post Thanks / Like
    Mentioned
    249 Post(s)
    Tagged
    17 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    How are you trying to run it?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  5. #5
    New Member
    Join Date
    Feb 2015
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    It works Thanks a lot. You will hear alot from me

  6. #6
    New Member
    Join Date
    Feb 2015
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    one last question. Is there way to this all by calling the print dialogue screen?

  7. #7
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    13,513
    Post Thanks / Like
    Mentioned
    249 Post(s)
    Tagged
    17 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    Fraid I don't understand what you're asking.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

  8. #8
    New Member
    Join Date
    Feb 2015
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    nevermind this is good enough. thanks again

    Quote Originally Posted by Fluff View Post
    Fraid I don't understand what you're asking.

  9. #9
    New Member
    Join Date
    Feb 2015
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    Can you please help me to add something in this code that I will be able to cancel while printing? When it starts printing even if I press cancel it doesn't stop. Also it prints the blank sheets too.

    Thanks a lot

    Quote Originally Posted by raymangoose View Post
    nevermind this is good enough. thanks again

  10. #10
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    13,513
    Post Thanks / Like
    Mentioned
    249 Post(s)
    Tagged
    17 Thread(s)

    Default Re: Add a Confirmation Message Box to a macro?

    Can you please help me to add something in this code that I will be able to cancel while printing?
    I don't know if that's possible, let alone how to do it, assuming that it is possible.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 2003 & 2013 on Win 7

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
  •