View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Help with Selecting multiple Checkboxes on a form

Option Explicit
Private Sub CommandButton2_Click()
Dim ctrl As control 'msforms.CheckBox
for each ctrl in me.controls
if typeof ctrl is msforms.checkbox then
if ctrl.caption = "----------" then
'do nothing
else
ctrl.value = true
end if
end if
next ctrl
End Sub

"Corey ...." wrote:

I am trying to use a CommnadButton on a form to Select ALL Checkboxes on a
form IF the CheckBox Caption is NOT "----------".
However i keep getting a error on the below identified line, why ?

Private Sub CommandButton2_Click()
Dim chx As CheckBox
With UserForm6
If chx.Caption < "----------" Then '<==== ERROR
For Each chx In UserForm6
chx.box = True
Next chx
End If
End With
End Sub

How can i fix this?

Corey....


--

Dave Peterson