Results 1 to 11 of 11

Msgbox vbYesNo if then

Threaded View

Swoootie Msgbox vbYesNo if then 06-24-2014, 05:26 AM
HaHoBe Re: Msgbox vbYesNo if then 06-24-2014, 05:40 AM
HaHoBe Re: Msgbox vbYesNo if then 06-24-2014, 05:48 AM
Swoootie Re: Msgbox vbYesNo if then 06-24-2014, 06:05 AM
HaHoBe Re: Msgbox vbYesNo if then 06-24-2014, 06:18 AM
Swoootie Re: Msgbox vbYesNo if then 06-24-2014, 05:47 AM
Kaper Re: Msgbox vbYesNo if then 06-24-2014, 05:49 AM
Swoootie Re: Msgbox vbYesNo if then 06-24-2014, 06:03 AM
Swoootie Re: Msgbox vbYesNo if then 06-24-2014, 06:31 AM
HaHoBe Re: Msgbox vbYesNo if then 06-24-2014, 06:53 AM
Swoootie Re: Msgbox vbYesNo if then 06-24-2014, 09:22 AM
  1. #1
    Registered User
    Join Date
    06-10-2012
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    30

    Unhappy Msgbox vbYesNo if then

    Hi all,

    I've got a piece of code that takes the user entered responses in a message box to do a set number of things.
    I want it to work in a way that if the user clicks no the sheet shuts down and no further code is run. If the user clicks yes I want the code to continue.

    As it stands, my code shuts down the document irrespective of what is selected by the user. I understand that this is because the shutting down of the workbook happens outside the If statement, but I don’t know how to correct this so that it does what I would like it to do.


    It looks like this at the moment:

    Public Opt as Variant
    Sub Check()
    Dim response As Variant
    Dim message As String
    Sheets("Front Page").select
    If Range("A2") = 1 then Opt = "1"
    If Range("A2") = 2 then Opt = "2"
    MESSAGE = "YOU CHAVE CHOSEN OPTION "& APPROACH & "IS THIS RIGHT?"
    response = msgbox(MESSAGE, vbYesNo)
    
    if response = vbNo then 
    Application.DisplayAlerts = False
        Workbooks("SHEET1.xlsm").Close
     Application.DisplayAlerts = True
    Exit Sub 
    
    If Response = vbYes then Sheets("Summary").Select
    
    End Sub
    Any help would be greatly appreciated.

    Thanks
    Last edited by Swoootie; 06-24-2014 at 05:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Having trouble with msgbox vbYesNo
    By Tayjayt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2013, 12:55 AM
  2. msgbox vbyesno
    By newbielondon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2012, 06:25 PM
  3. MsgBox vbYesNo and Exit Sub
    By Monkeyboyz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2010, 12:46 PM
  4. any way to scroll around the worksheet when a msgbox prompts for a vbyesno choice
    By christheta in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-19-2010, 04:44 PM
  5. [SOLVED] VBYesNo MsgBox - Computer always says "Yes"
    By Peter Rooney in forum Excel General
    Replies: 4
    Last Post: 12-22-2005, 10:45 AM

Tags for this Thread

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