MsgBox cancel or Continue macro

jl2509

Board Regular
Joined
Oct 30, 2015
Messages
139
Hi

Can anyone advise for a macro that will check cell A2 for a value of "True"
If cell A2 does contain "True" then return a messagebox "Are you sure this is the correct selection?" vbyesno
if vbyes is pressed then continue with code or if no is selected exit sub

This must be run from a command button as this is a print routine.

I know this is miles away, but this is my thought process.

If Range("A2") = True Then

MsgBox "Are you sure this is the correct selection?", vbYesNo
if response = vbYes
continue code
.....
.....
if response = vbno then
exit sub


many thanks
 

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
1,972
Code:
Sub CheckIt()    Dim s As String
    
    'set message
    s = "Are you sure this is the correct selection?"
    
    'make cae insesnsitive
    If UCase([A2]) = "TRUE" Then
        'ask question and leave if negative
        If MsgBox(s, vbYesNo) = vbNo Then Exit Sub
    End If
    
End Sub
 

jl2509

Board Regular
Joined
Oct 30, 2015
Messages
139
Thank you for the repsonse,

I know I cross posted but only in my haste to get a solution.

Thanks
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,739
Office Version
365
Platform
Windows
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Forum statistics

Threads
1,085,586
Messages
5,384,592
Members
401,913
Latest member
chethan av

Some videos you may like

This Week's Hot Topics

Top