ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control Cell Link for Option Button based on value in a cell (https://www.excelbanter.com/excel-programming/297258-control-cell-link-option-button-based-value-cell.html)

arunjoshi[_14_]

Control Cell Link for Option Button based on value in a cell
 
I have two option buttons on a sheet. In cell A1, on the same sheet
there is a value which can be either 1 or 2.

Can you help me achieve this? ...

If the value in cell A1 is 1, then the Control Cell Link for the tw
option buttons should become cell B1.

If the value in cell A1 is 2, then the Control Cell Link for the tw
option buttons should become cell B2

--
Message posted from http://www.ExcelForum.com


rick

Control Cell Link for Option Button based on value in a cell
 
Sub TestLinks()
If ActiveSheet.Cells(1).Value = "1" Then
ActiveSheet.Shapes("OB No. 1").Select
Selection.LinkedCell = "B1"
Range("A1").Select
ElseIf ActiveSheet.Cells(1).Value = "2" Then
ActiveSheet.Shapes("OB No. 1").Select
Selection.LinkedCell = "B2"
Range("A1").Select
End If
End Sub

Assign this macro to each option button. In my test case,
if I changed the linked cell for one option button (which
I named "OB No. 1"), it changed all of them. For some
reason I had to select the option button object first.
There may be another way to write this by by-passing the
selection process. But this works in the meantime....

Rick

-----Original Message-----
I have two option buttons on a sheet. In cell A1, on the

same sheet,
there is a value which can be either 1 or 2.

Can you help me achieve this? ...

If the value in cell A1 is 1, then the Control Cell Link

for the two
option buttons should become cell B1.

If the value in cell A1 is 2, then the Control Cell Link

for the two
option buttons should become cell B2.


---
Message posted from http://www.ExcelForum.com/

.



All times are GMT +1. The time now is 07:24 AM.

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