VBA - Select an optionbutton, dynamically changes the caption of another optionbutton

Evapar18

Board Regular
Joined
Aug 3, 2018
Messages
86
Office Version
  1. 2019
Platform
  1. Windows
Hello all,
I am trying to make a user request form in excel for file requests and I need to select an "engine brand" and it changes the options buttons under "engine liter".

File: File Request Form.xlsx - Shared with pCloud

There may be an easier way to make this work but unfortunately, my company won't send me to training. So I learn what I can by searching and posting.

VBA Code:
Private Sub OptionButton9_Click()

If OptionButton5 = True Then
OptionButton9.Caption = "D10"

ElseIf OptionButton6 = True Then
ActiveSheet.Shapes("OptionButton9").TextFrame.Characters.Text = "N45"

ElseIf OptionButton7 = True Then
OptionButton9 = "S4S Series"

ElseIf OptionButton5 = False Then
OptionButton9 = ""

ElseIf OptionButton6 = False Then
OptionButton9 = ""

ElseIf OptionButton7 = False Then
OptionButton9 = ""

End If

End Sub

Thanks,
Scott
If there is a better way please enlighten me.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You have not explained what your object is here. And what type Option Buttons are you using and I do not believe a Option Button can have a value of ""
 
Upvote 0
They are "Active X" option buttons within my spreadsheet, not on a user form. As for "", it can be anything "X". I just don't have an option if nothing is selected at the moment.
Option Buttons.jpg


The object is to select the brand then be able to select the engine liter. After the selections are made to export each selected item to "X" cells, which have not been determined yet.

I should add, that I have each of the option buttons in their own group. 3 in "Engine_Brand" and 5 in "Engine_Liter".

Does that help?
 
Upvote 0
I see option buttons and checkboxes.

So what is your question?
You said export to x cells.

That is not specific at all. What does export mean?
And I cannot help with such a vague reference as to export to x cells.
 
Upvote 0
My question is when I select "FPT" that the Options buttons under "Engine Liter" changes to "N45" and another to "N67", the others can be blank or "X". If I select "Mitisbushi" then the options buttons can be "SS-Series", "ST-Series", rest blank or "X". If "Doosan" is selected the ones showing the image above are shown and can be selected. The end goal will be to copy all the selections to a series of cells, but I think I can do that when I add the button. Right now I just want to be able to rename the captions of each of the Options buttons under the "Engine Liter", per the selection of the Engine Brand. - I hope this makes better sense.
 
Upvote 0
Well here is a example.
You did not provide the names of the option buttons or checkboxes.
So here is a example.

VBA Code:
Private Sub OptionButton1_Click()
'Modified  12/2/2019  4:21:41 PM  EST
If OptionButton1.Value = True Then CheckBox1.Caption = "N45"
End Sub
 
Upvote 0
Thanks for the replies! I will give that try.

FYI I uploaded the spreadsheet, I thought that would make it easier to see the problem(s). Also, I have since moved this over to a module so its not specific to the optionbutton1 click. I don't even know if that is right to do or not. I also think that I should try something else since this seems too hard to explain.
 
Upvote 0
A lot of people on this forum have no problem down loading users files to their computers and writing all the code for the user. But I do not do that.

And
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

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