+ Reply to Thread
Results 1 to 4 of 4

MsgBox problem

Hybrid View

DavidBre MsgBox problem 05-10-2014, 03:42 AM
DavidBre Re: MsgBox problem 05-10-2014, 05:38 AM
HaHoBe Re: MsgBox problem 05-10-2014, 05:45 AM
DavidBre Re: MsgBox problem 05-10-2014, 06:52 AM
  1. #1
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    MsgBox problem

    Hi all, I am new to the forum and have some basic knowledge of Excel and VBA. I am trying to run macro that has a MsgBox that will stop the macro if No is selected. I am getting all kinds of errors. I have tried to alter it but not getting the response i want.

    This is where i am up to so far:

    Dim iresponse As Integer
        iresponse = MsgBox("Is data ok, and is it ok to continue?", vbYesNo + vbQuestion + vbDefaultButton1, "Data Curruption!")
        Select Case iresponse
            Case vbNo
                Dim response
                response = MsgBox("Are you sure you want to stop program?", vbYesNo + vbQuestion + vbDefaultButton1, "Data Curruption!?")
                If MsgBox = vbYes Then
                Exit Sub
                ElseIf MsgBox = vbNo Then
                End If
    Many thanks!
    Last edited by DavidBre; 05-10-2014 at 05:35 AM.

  2. #2
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: MsgBox problem

    Appologise Fotis, I have upadted now. Thanks.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: MsgBox problem

    Hi, DavidBre,

    in your code you assign a value to a variable named response but check MsgBox - you should use response there.

    If MsgBox("Is data ok, and is it ok to continue?", vbYesNo + vbQuestion + vbDefaultButton1, "Data Curruption!") = vbNo Then
      If MsgBox("Are you sure you want to stop program?", vbYesNo + vbQuestion + vbDefaultButton1, "Data Curruption!?") = vbYes Then
        Exit Sub
      End If
    End If
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: MsgBox problem

    Hi Holger,

    Just how i wanted it to work, much appreciated!

    Many thanks,

    David

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Problem with VBA Editor uses lower case on some lines (ex. msgbox instead of MsgBox)
    By stubbsj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2013, 06:59 PM
  2. Problem in msgbox
    By girishkini in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2013, 02:27 AM
  3. msgBox problem
    By bernie1961 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2008, 08:53 AM
  4. [SOLVED] Problem with Msgbox Code
    By Old Dog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2005, 09:20 PM
  5. MsgBox problem
    By plockey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2005, 02:31 PM

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