custom button on a msgbox

BORUCH

Well-known Member
Joined
Mar 1, 2016
Messages
548
Office Version
  1. 365
Platform
  1. Windows
Hi

Im looking for some help with an excel vba msgbox ,but i do not want to use the standard buttons i would like to have three custom buttons that i would name myself

Any help is appreciated
 

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,
whilst it is possible to do what you want & here is one example how that you can read here:Create Custom Button Labels for a VBA MsgBox - wellsr.com
but there are others who have published similar suggestions you can search for.

Personally, I would just create my own from a Userform which gives you access to each controls properties like, colour, size etc that you can easily change.

Dave
 
Upvote 0
Hi,
whilst it is possible to do what you want & here is one example how that you can read here:Create Custom Button Labels for a VBA MsgBox - wellsr.com
but there are others who have published similar suggestions you can search for.

Personally, I would just create my own from a Userform which gives you access to each controls properties like, colour, size etc that you can easily change.

Dave
Hi

Would you be able to attach some type of small user form (msg box) and how to capture the entries of each button?
 
Upvote 0
Hi,
can give it a go - Go to VB editor (Alt+F11) > Insert > UserForm

Create the userform as shown in image with following Controls

Name the userform frmMsgBox

- Two Labels named
PromptLabel
ButtonsPanel

- Three commandButtons named
Button1
Button2
Button3

ENSURE that you name these controls as shown - You should also rename the control captions as shown

while you are doing that will start typing some code - let me know when done.

Dave

frmMsgBox.jpg
 
Upvote 0
Hi,
can give it a go - Go to VB editor (Alt+F11) > Insert > UserForm

Create the userform as shown in image with following Controls

Name the userform frmMsgBox

- Two Labels named
PromptLabel
ButtonsPanel

- Three commandButtons named
Button1
Button2
Button3

ENSURE that you name these controls as shown - You should also rename the control captions as shown

while you are doing that will start typing some code - let me know when done.

Dave

View attachment 48743
hi

i created the above basically what i would like is to add this user form to my code below in my macro

VBA Code:
End If
    Path = "g:\Office\test\test123\"
    FileName = Range("A1").Value & " " & Range("b1").Value & " " & Format(Now, "mm-dd-yyyy") & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook

i would like to add to the file name before the date the buttons i clicked on. so for ex.
If i click button 1 then it should name the file range a1.... etc.. and "button 1 or whatever i decide to name the button

Thanks
 
Upvote 0
The standard msgbox returns an integer of value between 1 - 7 depending on which button is selected.
Any form I create would use the Msgbox enumeration - changing the captions would not change the selected buttons value.
E.G. If you selected Button1 as vbYes then Its return value will be 6 but its caption could be anything you decide.

I should also mention I will not be including the Icons.

But before get too deep is this what you are thinking of with standard msgbox?

VBA Code:
Dim response As VbMsgBoxResult
    Path = "g:\Office\test\test123\"
    Filename = Range("A1").Value & " " & Range("b1").Value & " " & Format(Now, "mm-dd-yyyy") & ".xlsx"
    
    response = MsgBox(Filename & Chr(10) & "Do You Want To Save The File?", vbYesNo, "Save File")
    If response = vbNo Then Exit Sub
    ActiveWorkbook.SaveAs Path & Filename, xlOpenXMLWorkbook

This will produce msgbox prompt with YesNo buttons

If this is not what you are thinking can you provide more specific code from your project with captions you would want to apply?

Dave
 
Upvote 0
The standard msgbox returns an integer of value between 1 - 7 depending on which button is selected.
Any form I create would use the Msgbox enumeration - changing the captions would not change the selected buttons value.
E.G. If you selected Button1 as vbYes then Its return value will be 6 but its caption could be anything you decide.

I should also mention I will not be including the Icons.

But before get too deep is this what you are thinking of with standard msgbox?

VBA Code:
Dim response As VbMsgBoxResult
    Path = "g:\Office\test\test123\"
    Filename = Range("A1").Value & " " & Range("b1").Value & " " & Format(Now, "mm-dd-yyyy") & ".xlsx"
   
    response = MsgBox(Filename & Chr(10) & "Do You Want To Save The File?", vbYesNo, "Save File")
    If response = vbNo Then Exit Sub
    ActiveWorkbook.SaveAs Path & Filename, xlOpenXMLWorkbook

This will produce msgbox prompt with YesNo buttons

If this is not what you are thinking can you provide more specific code from your project with captions you would want to apply?

Dave
i dont need a msg box i need to be able to have the file name changed acording to the button i press ,so i f the first button is called john then the file name is john with date etc..
 
Upvote 0
i dont need a msg box i need to be able to have the file name changed acording to the button i press ,so i f the first button is called john then the file name is john with date etc..

OK confused now as title of your thread requested a custom button on a msgbox?

If not a msgbox then perhaps helpful to forum if you could create a userform with required butons & captions & explain how you want your code to work with it?


Dave
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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