Status
Not open for further replies.

ateebali

Board Regular
Joined
Dec 13, 2018
Messages
108
Dear, I am using following code but giving some error.
If cell value A1 is blank option button is hidden
when put any value in A1, it should assign as option button caption
same goes till A7


Sub optionbutton()
'
' optionbutton Macro
'
Private Sub Worksheet_Change(ByVal Target As Range)
Me.OptionButtons("Option Button 1").Visible = Len(Me.Cells(1, 1)) > 0
Me.OptionButtons("Option Button 2").Visible = Len(Me.Cells(2, 1)) > 0
Me.OptionButtons("Option Button 3").Visible = Len(Me.Cells(3, 1)) > 0
Me.OptionButtons("Option Button 4").Visible = Len(Me.Cells(4, 1)) > 0
Me.OptionButtons("Option Button 5").Visible = Len(Me.Cells(5, 1)) > 0
Me.OptionButtons("Option Button 6").Visible = Len(Me.Cells(6, 1)) > 0
Me.OptionButtons("Option Button 7").Visible = Len(Me.Cells(7, 1)) > 0




End Sub


'
ActiveSheet.Shapes.Range(Array("Option Button 1")).Select
Selection.Characters.Text = Range("A1")
ActiveSheet.Shapes.Range(Array("Option Button 2")).Select
Selection.Characters.Text = Range("A2")
ActiveSheet.Shapes.Range(Array("Option Button 3")).Select
Selection.Characters.Text = Range("A3")
ActiveSheet.Shapes.Range(Array("Option Button 4")).Select
Selection.Characters.Text = Range("A4")
ActiveSheet.Shapes.Range(Array("Option Button 5")).Select
Selection.Characters.Text = Range("A5")
ActiveSheet.Shapes.Range(Array("Option Button 6")).Select
Selection.Characters.Text = Range("A6")
ActiveSheet.Shapes.Range(Array("Option Button 7")).Select
Selection.Characters.Text = Range("A7")


End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Last edited:
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,333
Messages
6,124,317
Members
449,153
Latest member
JazzSingerNL

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