ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SIMPLE UserForm w/ 2 OPTION BUTTONS (https://www.excelbanter.com/excel-programming/313114-simple-userform-w-2-option-buttons.html)

Chuckles123[_38_]

SIMPLE UserForm w/ 2 OPTION BUTTONS
 

Below is the code for a 'main macro' and code for each of two Optio
Buttons.
You may find this useful in situations when you want to direct contro
to either of two sections of code based upon user selection o
alternatives presented.

Public Button As String
Sub CREATE_FORM()
'
frmPricing.Show
'SHOW Pricing UserForm ON DISPLAY

'USER SELECTS BUTTON

'AFTER SELECTION, CONTROL COMES BACK HERE
If Button = "EVAL" Then
Range("A1").Select

Else
Range("C1").Select
End If

End Sub

‘BELOW IS CODE FOR EACH OF 2 OPTION BUTTONS

Private Sub optEVAL_Prices_Click()
Button = "EVAL"
Unload Me
End Sub

Private Sub optBID_Prices_Click()
Button = "BID"
Unload Me
End Sub

The only missing steps are the assignment of a programmatic name and a
UserForm name to each of the Option Buttons, a Frame around the Button
(if so desired), and the UserForm itself.

You may find this useful in lieu of a MsgBox.

Chuckles12

--
Chuckles12
-----------------------------------------------------------------------
Chuckles123's Profile: http://www.excelforum.com/member.php...fo&userid=1494
View this thread: http://www.excelforum.com/showthread.php?threadid=26805


Bob Phillips[_6_]

SIMPLE UserForm w/ 2 OPTION BUTTONS
 
It might be better to make code offered like this more generic, such as
adding constants for string values so that the number of customisations are
minimised. Not a big deal here, but with bigger code samples it can save
pain.

--

HTH

RP

"Chuckles123" wrote in message
...

Below is the code for a 'main macro' and code for each of two Option
Buttons.
You may find this useful in situations when you want to direct control
to either of two sections of code based upon user selection of
alternatives presented.

Public Button As String
Sub CREATE_FORM()
'
frmPricing.Show
'SHOW Pricing UserForm ON DISPLAY

'USER SELECTS BUTTON

'AFTER SELECTION, CONTROL COMES BACK HERE
If Button = "EVAL" Then
Range("A1").Select

Else
Range("C1").Select
End If

End Sub

'BELOW IS CODE FOR EACH OF 2 OPTION BUTTONS

Private Sub optEVAL_Prices_Click()
Button = "EVAL"
Unload Me
End Sub

Private Sub optBID_Prices_Click()
Button = "BID"
Unload Me
End Sub

The only missing steps are the assignment of a programmatic name and an
UserForm name to each of the Option Buttons, a Frame around the Buttons
(if so desired), and the UserForm itself.

You may find this useful in lieu of a MsgBox.

Chuckles123


--
Chuckles123
------------------------------------------------------------------------
Chuckles123's Profile:

http://www.excelforum.com/member.php...o&userid=14948
View this thread: http://www.excelforum.com/showthread...hreadid=268057





All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com