Sebastian K.
New Member
- Joined
- Jul 19, 2011
- Messages
- 16
Hi
Need a bit of help.
I'm using a bunch of checkboxes to show/hide graphs i a chart.
I want to set a variable as an object which is combined of a string and an integer, like this.
Where chk is the object for use in the code whiche hides/shows the graph. The CId is a variable that depends on which CheckBox I toggle.
As it is right now it doesn't work, is there any way to do what I want to?
Essentially it is only a matter of avoiding having ti write the same code for each checkbox.
Best regards
Sebastian
Need a bit of help.
I'm using a bunch of checkboxes to show/hide graphs i a chart.
I want to set a variable as an object which is combined of a string and an integer, like this.
Code:
Set chk="CheckBox" & CId
Where chk is the object for use in the code whiche hides/shows the graph. The CId is a variable that depends on which CheckBox I toggle.
Code:
Dim rng As Range, chk As Object, CId As Integer
Private Sub CheckBox1_Click()
CId = 1
ToggleColumn
End Sub
Private Sub CheckBox10_Click()
CId = 2
ToggleColumn
End Sub
Private Sub ToggleColumn()
chk = "CheckBox" & CId
rng = Range(Cells(22, 5 + CId))
If chk.Value = True Then
rng.EntireColumn.Hidden = False
Else: rng.EntireColumn.Hidden = True
End If
End Sub
As it is right now it doesn't work, is there any way to do what I want to?
Essentially it is only a matter of avoiding having ti write the same code for each checkbox.
Best regards
Sebastian