Posted to microsoft.public.excel.programming
|
|
Check Box checking
Many Thanks Rick
I'll give it a go
Steve
"Rick Rothstein (MVP - VB)" wrote:
Something like this maybe (using a CommandButton to enact the code for
example purposes only)...
Private Sub CommandButton1_Click()
Dim Cnt As Long
Dim Ctrl As Control
Dim ChkBxArray() As String
ReDim ChkBxArray(1 To 12)
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Value Then
Cnt = Cnt + 1
ChkBxArray(Cnt) = Ctrl.Name
End If
End If
Next
ReDim Preserve ChkBxArray(1 To Cnt)
' Prove it worked
For Cnt = 1 To UBound(ChkBxArray)
Debug.Print ChkBxArray(Cnt)
Next
End Sub
Rick
"Steve" wrote in message
...
Apologies
They are on a user form
"Rick Rothstein (MVP - VB)" wrote:
Where are the CheckBoxes at... directly on the worksheet or on a
UserForm?
If on the worksheet, where did they come from... the Forms Toolbar or the
Visual Basic toolbar?
Rick
"Steve" wrote in message
...
Hi
I have 12 check boxes for each month.
Is there a quick way of looping through all the check boxes to see if
they
are ticked or not?
I then want to write the info to an array.
Thanks
Steve
|