Just full of ?'s today vbOkay Cancel

itsme2

Board Regular
Joined
Jul 29, 2006
Messages
66
Thanks for all the help so far so good as they say...

Why does this always run the application no matter whether "Cancel" or Okay is selected?

As you can see I've been trying several solutions however, am I missing the big picture here or something? I thought "Cancel was Cancel no matter what but, in my case "Cancel" is still running my next macro

Code:
If Range("B1") = "ABC" Then
        MsgBox "ABC", vbOKCancel & " for " & Range("A6").Value
        'ActiveSheet.Delete
        'Exit Sub
        'Else
        Application.Run "ABC"
        'Exit Sub
    End If

I wanted the message box to run like this under the above If statement but by golly, no go

MsgBox Range("B1").Value & " " & Range("A6").Value & Range("A7").Value, vbOKCancel

but the If statement before it makes excel a very unhappy person

:-P
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

do some test with this
you pust put the "click-choice" in a variable
Code:
Sub test()
Dim response As Integer

If Range("B1") = "ABC" Then
    response = MsgBox("ABC", vbOKCancel, " for " & Range("A6").Value)
    If response = vbOK Then Application.Run "ABC"
End If
End Sub

Sub ABC()
MsgBox "ABC"
End Sub
compact
Code:
Sub another()
If MsgBox("do you?", vbOKCancel, "title") = vbOK Then MsgBox "OK" Else MsgBox "cancel"
End Sub
kind regards,
Erik
 
Upvote 0
Thanks ran with that and all is well thank you very much!!!!!

One other question regarding message boxes... how can you make a new line for each field in the message box ex

abc
def
ghi

Okay Cancel

IS what the message box would appear to look like in case the strings are very long ... if you know what I mean...

:)
 
Upvote 0
Great thanks couldn't remember nor find anything on VB lineFeed

Great Help Today Thanks a Bunch!!!!!!
 
Upvote 0

Forum statistics

Threads
1,224,882
Messages
6,181,546
Members
453,053
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top