series of Checkboxes to select worksheet's data

B

brucelim80

hi,

Can anyone help me with this problem?

I have a series of checkboxes on one form which allow user to select
any mixture of checkbox and click on the generate button to transfer
the selected worksheet's data on to a consolidated worksheet.


How do i write a code to extract the series of checkboxes selected and
perform certain action.

Thank you,

Regards,
Bruce
 
B

Bob Phillips

Bruce,

Here is how to test all the checkboxes, assuming that it is Forms toolbar
checkboxes

Sub Macro1()
Dim cb As CheckBox
For Each cb In ActiveSheet.CheckBoxes
If cb.Value = 1 Then
Debug.Print cb.Name
End If
Next cb
End Sub

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 
B

brucelim80

hi again,
Thank for your help. However, it seem that it cant work.
The form i am referring to is a VBA form which you create under the
viual basic script editor.

Thank
 
B

Bob Phillips

Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then
Debug.Print ctl.Name
End If
Next ctl


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 
B

brucelim80

hi ,
Thank for your help. sorry i need your help again.

How do i display those that have been ticked instead of all the
checkboxes? I had tried your code and it display all the name of the
checkbox.
 
B

Bob Phillips

You just test the value for True

Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then
If ctl.Value Then
Debug.Print ctl.Name
End If
End If
Next ctl


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top