custom userform to emulate msgbox

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
how can i get a userform to emulate the vb msgbox answer? like vbok is 6?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I'm replacing my program
the program was deigned with the standard Msgboxes but I need it to be modeless. If I can get a way for a user form to return an answer to the macro in an integer value 1-6
 
Upvote 0
no it has to be a command button
Here is an example if a msgbox i need to convert to a usserform

VBA Code:
Sub MsgBox_1()
 
Dim answer As Integer
answer = MsgBox("Are you ready to start the night audit file process?" & vbNewLine _
& "This is for the date of: " & Format(Date - 1, "mm-dd-yyyy"), vbQuestion + vbYesNoCancel, "Night Audit Processing  Step 1 of 5")
 
  If answer = vbYes Then
  Call PNT2
  MsgBox "Nihgt Audit Checklist printed"
  'Call pmtpause
  Call Makefolder
  Call FolderPicker
    Call Msgbox_1A
  ElseIf answer = vbNo Then
    MsgBox "Click Start prior to running audit in Opera when ready.", , "Night Audit Processing"
  Else
    Call Reset
  End If
End Sub
 
Upvote 0
if i can get a command button to return the "answer" as a number I can keep the same if then structure but i also dont know how to get the code to wait for a button to be selected
here is an example i was trying to h=get to work but it immediately shows message "dont"
Code:
Sub test()
    UserForm1.ShowMsg "hello", Title:="Testing Mode"
    
    If UserForm1.ShowMsg("Should I do it?", Button1Text:="Yes", Button2Text:="No") = "Yes" Then
        MsgBox "do it"
    Else
        MsgBox "don't"
    End If
End Sub
 
Upvote 0
or if you have a suggestion for a userform that behaves like a msgbox. Im new to working with userforms and not entirely sure how to get it to work in a similar fashion.
 
Upvote 0
Userform is not like a msgbox

In the userform if the "yes" button is pressed then you run a code for that button, if "no" button then run a code for that button.

Create the userform and have code for each button
VBA Code:
Private Sub CommandButton1_Click()
    MsgBox "You clicked the yes button"
End Sub

Private Sub CommandButton2_Click()
    MsgBox "You clicked the no button"
End Sub

Private Sub CommandButton3_Click()
    Unload Me
End Sub


1601530476961.png
 
Upvote 0
thanks so i have to rework the entire program thank you for the help and a good place to start.
 
Upvote 0

Forum statistics

Threads
1,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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