Creating an Array of Checkboxes

johnmiko4

New Member
Joined
Jun 11, 2013
Messages
2
Hi there I'm having some difficulty creating an array that contains the name of a bunch of activex checkboxes that are on an excel spreadsheet. The error I get says type mismatch and highlights the & symbol. I want to make a list of checkboxes so I can use a for loop instead of writing out each checkbox code individually. Here is what part of my code looks like. If my code doesn't make sense I want Time(0) = ThirteenJan

Dim Month(0 To 11) As String
Dim Year(0 To 3) As String
Dim Time(0 To 47) As CheckBox
Dim i, j, k, l, m As Integer


'The initial values of the months were named such because that is how the buttons have been named
'Initial Values
Month(0) = "Jan"
Month(1) = "Feb"
Month(2) = "Mar"
Month(3) = "Apr"
Month(4) = "May"
Month(5) = "Jun"
Month(6) = "Jul"
Month(7) = "Aug"
Month(8) = "Sep"
Month(9) = "Oct"
Month(10) = "Nov"
Month(11) = "Dec"


Year(0) = "Thirteen"
Year(1) = "Fourteen"
Year(2) = "Fifteen"
Year(3) = "Sixteen"


k = 0


'I can't get the following code to work and I'm not sure what's wrong with it. It says type mismatch and highlights the &.
'Create an array that has all the names of the checkboxes in each element of it
For i = 0 To 3
For j = 0 To 11
Set Time(k) = Year(i) & Month(j)
k = k + 1
Next j
k = k + 1
Next i


k = 4
l = 18


For i = LBound(Time) To UBound(Time)
'j loops through worksheets, the summary sheets are organized differently than the rest of the workbook so they have to have their own code
For j = 2 To 3
'k loops through the columns, 54 is Column BB
If k = 16 Or k = 29 Or k = 42 Then
k = k + 1
End If
If Time(i).Value = True Then
Sheets(j).Columns(k).EntireColumn.Hidden = False
Else
Sheets(j).Columns(k).EntireColumn.Hidden = True
End If
Next j
For j = 4 To 9
If l = 30 Or l = 31 Or l = 44 Or l = 45 Or l = 58 Or l = 59 Then
l = l + 1
End If
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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