Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Start a Macro by physically checking a check box? Mr Imnotabrainsurgeon Excel Discussion (Misc queries) 3 September 24th 09 09:11 PM
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
Checking range of cells for entry then checking for total Barb Reinhardt Excel Programming 1 October 13th 06 02:47 PM
Why does spelling check close Excel when checking spanish? RCP Excel Discussion (Misc queries) 2 December 4th 04 07:37 PM


All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"