Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
You want to know what? Which ones are checked, how many are checked, if any
at all are checked, if none are checked. Pick one. "Steve" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
Which ones are checked
"JLGWhiz" wrote: You want to know what? Which ones are checked, how many are checked, if any at all are checked, if none are checked. Pick one. "Steve" wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
Hi Steve,
Try something like: '========== Option Explicit Dim arr(1 To 12) As Boolean '------------ Private Sub CommandButton1_Click() Dim Ctrl As msforms.Control Dim i As Long For Each Ctrl In Me.Controls With Ctrl If TypeOf Ctrl Is msforms.CheckBox Then i = i + 1 arr(i) = .Value End If End With Next Ctrl End Sub '------------ Private Sub CommandButton2_Click() MsgBox arr(1) End Sub '<<========== --- Regards. Norman "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 |
#8
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 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check Box checking
Many Thanks Norman
I'll give it a go. Appreciate your time. regards Steve "Norman Jones" wrote: Hi Steve, Try something like: '========== Option Explicit Dim arr(1 To 12) As Boolean '------------ Private Sub CommandButton1_Click() Dim Ctrl As msforms.Control Dim i As Long For Each Ctrl In Me.Controls With Ctrl If TypeOf Ctrl Is msforms.CheckBox Then i = i + 1 arr(i) = .Value End If End With Next Ctrl End Sub '------------ Private Sub CommandButton2_Click() MsgBox arr(1) End Sub '<<========== --- Regards. Norman "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to Start a Macro by physically checking a check box? | Excel Discussion (Misc queries) | |||
Spell Checking with checking cell notes | Excel Discussion (Misc queries) | |||
Check if Conditional Format is True or False / Check cell Color | Excel Worksheet Functions | |||
Checking range of cells for entry then checking for total | Excel Programming | |||
Why does spelling check close Excel when checking spanish? | Excel Discussion (Misc queries) |