userform option button to worksheet text value

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,931
Office Version
  1. 2007
Platform
  1. Windows
Morning,
Below is part of my code is in use which works fine apart from the Option Button code.
On my userform i have 4 Option buttons.
OptionButton1 = 41601
OptionButton2 = UPRATED 41601
OptionButton3 = 41835
OptionButton4 = UPRATED 41835

The user will only select one of these options but im not sure who to get the value into the worksheet cell correctly.
The current line of code below transfers to the correct cell but shows value as opposed to what the option button value is,make sense to you ?


Rich (BB code):
With ThisWorkbook.Worksheets("RANGER")
    .Range("B5").Value = TextBox1.Text
    .Range("D5").Value = TextBox2.Text
    .Range("F5").Value = TextBox3.Text
    .Range("C5").Value = ComboBox1.Text
    .Range("G5").Value = ComboBox2.Text
    .Range("H5").Value = ComboBox3.Text
    .Range("E5").Value = OptionButton1.Value
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,091
Office Version
  1. 2013
Platform
  1. Windows
set Caption
OptionButton1 = 41601
OptionButton2 = UPRATED 41601
OptionButton3 = 41835
OptionButton4 = UPRATED 41835

Then some thing like
VBA Code:
 For i = 1 To 4
        If Me.Controls("OptionButton" & i) = True Then
            .Range("E5").Value = Me.Controls("OptionButton" & i).Caption
        End If
    Next
 
Solution

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,091
Office Version
  1. 2013
Platform
  1. Windows
You are very welcome
And thank you for the feedback
Be happy
 

Watch MrExcel Video

Forum statistics

Threads
1,129,483
Messages
5,636,596
Members
416,927
Latest member
BNM8V6

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
Top