Modifying the vbYesNo buttons

noompsie

New Member
Joined
Jul 20, 2008
Messages
7
Hi,

The vbYesNo is a highly useful interactive button to combine with messageBoxes for the user to make a decision. But what if I want to quickly make one or more buttons that say something else on them but essentially do the same thing?

Does it have to be tricky?

e.g something like

MsgBox "Are you sure you want to move to the next shet?",vb"Yes,Please""NoThanks"

aaaarrrh. I'm stuck.:eeek:
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Afaik Userform is the only way to mimick a messagebox but using your own custom button captions.
 
Upvote 0
Hi,

The vbYesNo is a highly useful interactive button to combine with messageBoxes for the user to make a decision. But what if I want to quickly make one or more buttons that say something else on them but essentially do the same thing?

Does it have to be tricky?

e.g something like

MsgBox "Are you sure you want to move to the next shet?",vb"Yes,Please""NoThanks"

aaaarrrh. I'm stuck.:eeek:


Depends on what you define as "tricky", it's all relative.

This code will simulate what you are asking for, with a dialog frame.



Code:
Sub ButtonAlternative()
Const SheetID As String = "_Buttonz"
Dim btnDlg As DialogSheet
 
Application.ScreenUpdating = False
On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.DialogSheets(SheetID).Delete
Application.DisplayAlerts = True
Err.Clear
 
Set btnDlg = ActiveWorkbook.DialogSheets.Add
 
With btnDlg
.Name = SheetID
.Visible = xlSheetHidden
 
With .DialogFrame
.Height = 70
.Width = 280
.Caption = "Please confirm..."
End With
 
With .Buttons("Button 2")
.BringToFront
.Width = 60
.Caption = "Yes, please"
End With
 
With .Buttons("Button 3")
.BringToFront
.Width = 60
.Caption = "No, thanks"
End With
 
.Labels.Add 100, 50, 100, 100
.Labels(1).Caption = "Are you sure you want to move to the next sheet?"
Application.ScreenUpdating = True
 
If .Show = True Then
MsgBox "Your ''Yes, please'' code goes here", 64, "Yes was clicked"
Else
MsgBox "Your ''No, thanks'' code goes here", 64, "No was clicked"
End If
 
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
 
End With
End Sub



Additionally here are a couple examples on this link for admittedly overkill alternatives:
http://www.mrexcel.com/forum/showthread.php?t=70581
 
Last edited:
Upvote 0
Great thanks!

I'll take them all on board.

The Overkill one was a little torturous though, can't see myself ever needing that level of code.

:)
 
Upvote 0
Top Stuff Tom

With the code I can now eliminate a few Userforms and reduced the file size considerably

regards pike
 
Upvote 0
Just wanted to add - that dialogsheet is excellent. Never heard of it before.
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

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