Closed Thread
Results 1 to 9 of 9

msg box question

Hybrid View

  1. #1
    Registered User
    Join Date
    09-04-2007
    Posts
    67

    msg box question

    Lost it...had it written down but lost the directions...aghhhh

    Anyone?

    Also, Can I add a way so if I run a macro and the msg box pops up before the pops up when done, is there a way I can select yes to complete the macro or no to shut it down.
    Its important that I write a macro to delete a bunch of cells, but if the user does it by mystake - alot going on in that page - I would like a way to confirm the deletion - like yes to proceed or no to cancel. The macro just deletes some cells (but alot that the user may have already inputted) and the pages are protected but those cells.

    Helping a friend working on a project and these are about the last of things I have left. The file is big now - about 15-20 meg. Is there a place here where I can upload the final project for a viewing or anyone like to look at it. Of course you would be able to use it when all completed.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello jerryjaysr,

    I can answer you about adding the Yes No buttons to a message box. See the Example below...
    Dim Answer As Variant
    Dim Msg As String
      Msg = "Do you wish to exit the macro?"
        Answer = MsgBox Msb, vbYesNo+vbDefaultButton2
          If Answer = vbYes Then Exit Sub
    "No" is the default button. If you want the "Yes" button use vbDefaultButton1 constant instead of vbDefaultButton2.

    Sincerely.
    Leith Ross

  3. #3
    Registered User
    Join Date
    09-04-2007
    Posts
    67

    Not sure

    NOt sure if I am doing it right. Made a quick object box, created a macro,
    inserted the lines exactly from above and get syntax error when I run it on
    Answer = MsgBox Msb, vbYesNo+vbDefaultButton2

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    a typo

    Msb -> Msg

  5. #5
    Registered User
    Join Date
    09-04-2007
    Posts
    67

    Still not working

    now have:
    Answer = MsgBox Msg, vbYesNo+vbDefaultButton1

    and still get compile error: end of statement

    ?????

    Macro has exactly what LR wrote with the switch of msg and still does not work

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Answer = MsgBox(Msg, vbYesNo+vbDefaultButton1)

Closed 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