- Joined
- May 19, 2010
- Messages
- 7
- Reaction score
- 0
Good Morning,
I am working on a sheet in Excel that will include an option for the user to decide between three different states. These states will each be represented by a column and some marker representing the choice made.
For example something like this:
option 1 | option 2 | option 3
---------------------------------
___cb1__|__cb2__|__cb3___
___cb1__|__cb2__|__cb3___
My Problem is that I only want one of the options to be checked in other words I would need some kind of code unchecking the other two checkboxes or some code that enables me to only link the 3 option buttons (those in the same row).
Up until now I was experimenting with the following code:
As far as I have gotten I am pretty sure that I won't be able to complete the task in the way I started, as I would somehow need to access the names of the other two corresponding checkboxes to change their state. However I have run out of ideas as how to do that.
------
Thanks John
I am working on a sheet in Excel that will include an option for the user to decide between three different states. These states will each be represented by a column and some marker representing the choice made.
For example something like this:
option 1 | option 2 | option 3
---------------------------------
___cb1__|__cb2__|__cb3___
___cb1__|__cb2__|__cb3___
My Problem is that I only want one of the options to be checked in other words I would need some kind of code unchecking the other two checkboxes or some code that enables me to only link the 3 option buttons (those in the same row).
Up until now I was experimenting with the following code:
Sub Process_type()
Dim LRow As Integer
Dim LCol As Integer
Dim L0Range As String
Dim L1Range As String
Dim L2Range As String
' finding the name of the CheckBox in use and its position in the sheet
LName = Application.Caller
LRow = ActiveSheet.DrawingObjects(LName).TopLeftCell.Row
LCol = ActiveSheet.DrawingObjects(LName).TopLeftCell.Column
' accessing the other columns (haven't yet found a way to use Row + Column instead of the "Letter" part)
L0Range = "G" & CStr(LRow)
L1Range = "H" & CStr(LRow)
L2Range = "I" & CStr(LRow)
' checking if the CheckBox is checked and then adding some text in the corresponding field, should later on check those fields for other CheckBoxes and change their state to 0
If ActiveSheet.DrawingObjects(LName).Value > 0 Then
ActiveSheet.Range(L0Range).Value = LRow
ActiveSheet.Range(L1Range).Value = LCol
ActiveSheet.Range(L2Range).Value = LName
Else
ActiveSheet.Range(L0Range).Value = Null
ActiveSheet.Range(L1Range).Value = Null
ActiveSheet.Range(L2Range).Value = Null
End If
End Sub
[btw I used the CheckBoxes from the Form bar]Dim LRow As Integer
Dim LCol As Integer
Dim L0Range As String
Dim L1Range As String
Dim L2Range As String
' finding the name of the CheckBox in use and its position in the sheet
LName = Application.Caller
LRow = ActiveSheet.DrawingObjects(LName).TopLeftCell.Row
LCol = ActiveSheet.DrawingObjects(LName).TopLeftCell.Column
' accessing the other columns (haven't yet found a way to use Row + Column instead of the "Letter" part)
L0Range = "G" & CStr(LRow)
L1Range = "H" & CStr(LRow)
L2Range = "I" & CStr(LRow)
' checking if the CheckBox is checked and then adding some text in the corresponding field, should later on check those fields for other CheckBoxes and change their state to 0
If ActiveSheet.DrawingObjects(LName).Value > 0 Then
ActiveSheet.Range(L0Range).Value = LRow
ActiveSheet.Range(L1Range).Value = LCol
ActiveSheet.Range(L2Range).Value = LName
Else
ActiveSheet.Range(L0Range).Value = Null
ActiveSheet.Range(L1Range).Value = Null
ActiveSheet.Range(L2Range).Value = Null
End If
End Sub
As far as I have gotten I am pretty sure that I won't be able to complete the task in the way I started, as I would somehow need to access the names of the other two corresponding checkboxes to change their state. However I have run out of ideas as how to do that.
------
Thanks John