Can you get rid of the cancel button from a message box?

sundance82

New Member
Joined
Jul 2, 2012
Messages
23
Hi all

I was just wondering can you get rid of a Cancel button from a message box?

Kind regards

Rob
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If by cancel, you mean the cross, then no. Perhaps if you tell us what you are actually trying to do then someone will suggest an alternative
 
Upvote 0
By defalut Message Box will have 'OK' only. If you are getting Cancel then the code would be like below.

Code:
MsgBox "Hello", vbOKCancel

This LINK will give more info about Messge Box.

Regards
-Abi
 
Upvote 0
Thanks Abi thats great and a useful tutorial too. Bit of newbie to programming macros. I realised I actually meant to put input box rather than message box, does the same apply?

Cheers

Rob
 
Upvote 0
Rob ,

Better way is to handle Cancel button within VBA. When user clicks on Cancel , variable assigned to the input box will return false.

Test this code,

Code:
Sub test()


Testbox = Application.InputBox("Enter Something", Type:=3)


Select Case Trim(Testbox)
    Case False: MsgBox "You Clicked Cancel"
    Case "": MsgBox "No Data Entered"
    Case Else: MsgBox "You Entered :" & Testbox
End Select


End Sub
 
Upvote 0
Rob,

Inputbox does not work like Message Box. Instead you can go for a UserForm, if you don't want Cancel button.

Regards
-Abi
 
Upvote 0

Forum statistics

Threads
1,215,030
Messages
6,122,762
Members
449,095
Latest member
m_smith_solihull

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