Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default For...Loop to verify at least one checkbox = True

I have a UserForm with a Multipage Control (mpgPaint). Each Page is Named
pgColor1, pgColor2, pgColor3, pgColor4, pgColor5, & pgColor6. On each page
there are two checkboxes named chk1stSurfaceP1 & chk2ndSurfaceP1 (the number
1 represents what page it is on). How can I cycle through each page and make
sure at least 1 checkbox is true? This is what I have, but it does not seem
to work.

Dim i As Byte

If chkPaint.Value = True Then
Do
For i = 1 To 5
If mpgPaint.Pages(i - 1).CheckBox("chk1stSurfaceP" &
i).Value = False And _
mpgPaint.Pages(i - 1).CheckBox("chk2ndSurfaceP" &
i).Value = False Then
MsgBox ("You forgot to specify 1st or 2nd
Surface in Paint Color " & i & "."), vbCritical
StopCode = True
Exit For
End If
Next i
Loop Until mpgPaint.Pages(i - 1).Visible = False
End If

Thanks in Advance,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default For...Loop to verify at least one checkbox = True

Ryan,

Dim i As Byte

If chkPaint.Value = True Then
For i = 1 To 2
If Controls("chk1stSurfaceP" & i).Value = False And _
Controls("chk2ndSurfaceP" & i).Value = False Then
MsgBox ("You forgot to specify 1st or 2nd Surface in Paint Color " & i & "."), vbCritical
GoTo NotChecked
End If
Next i
End If

MsgBox "You checked the surfaces correctly."
Exit Sub
NotChecked:

HTH,
Bernie
MS Excel MVP


"RyanH" wrote in message
...
I have a UserForm with a Multipage Control (mpgPaint). Each Page is Named
pgColor1, pgColor2, pgColor3, pgColor4, pgColor5, & pgColor6. On each page
there are two checkboxes named chk1stSurfaceP1 & chk2ndSurfaceP1 (the number
1 represents what page it is on). How can I cycle through each page and make
sure at least 1 checkbox is true? This is what I have, but it does not seem
to work.

Dim i As Byte

If chkPaint.Value = True Then
Do
For i = 1 To 5
If mpgPaint.Pages(i - 1).CheckBox("chk1stSurfaceP" &
i).Value = False And _
mpgPaint.Pages(i - 1).CheckBox("chk2ndSurfaceP" &
i).Value = False Then
MsgBox ("You forgot to specify 1st or 2nd
Surface in Paint Color " & i & "."), vbCritical
StopCode = True
Exit For
End If
Next i
Loop Until mpgPaint.Pages(i - 1).Visible = False
End If

Thanks in Advance,
Ryan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default For...Loop to verify at least one checkbox = True

Oops.. I forgot to change

For i = 1 To 2

back to

For i = 1 To 6

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Ryan,

Dim i As Byte

If chkPaint.Value = True Then
For i = 1 To 2
If Controls("chk1stSurfaceP" & i).Value = False And _
Controls("chk2ndSurfaceP" & i).Value = False Then
MsgBox ("You forgot to specify 1st or 2nd Surface in Paint Color " & i & "."), vbCritical
GoTo NotChecked
End If
Next i
End If

MsgBox "You checked the surfaces correctly."
Exit Sub
NotChecked:

HTH,
Bernie
MS Excel MVP


"RyanH" wrote in message
...
I have a UserForm with a Multipage Control (mpgPaint). Each Page is Named
pgColor1, pgColor2, pgColor3, pgColor4, pgColor5, & pgColor6. On each page
there are two checkboxes named chk1stSurfaceP1 & chk2ndSurfaceP1 (the number
1 represents what page it is on). How can I cycle through each page and make
sure at least 1 checkbox is true? This is what I have, but it does not seem
to work.

Dim i As Byte

If chkPaint.Value = True Then
Do
For i = 1 To 5
If mpgPaint.Pages(i - 1).CheckBox("chk1stSurfaceP" &
i).Value = False And _
mpgPaint.Pages(i - 1).CheckBox("chk2ndSurfaceP" &
i).Value = False Then
MsgBox ("You forgot to specify 1st or 2nd
Surface in Paint Color " & i & "."), vbCritical
StopCode = True
Exit For
End If
Next i
Loop Until mpgPaint.Pages(i - 1).Visible = False
End If

Thanks in Advance,
Ryan





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 do I update a checkbox as true when another has been updated fishy Excel Worksheet Functions 1 September 10th 07 11:06 AM
deleting mulitple rows when the checkbox value = true. burgeee Excel Discussion (Misc queries) 1 January 30th 07 04:04 PM
If one checkbox = true damorrison Excel Discussion (Misc queries) 1 August 26th 06 01:47 PM
checkbox true/false label [email protected] Excel Programming 6 October 4th 05 04:11 PM
Checkbox toggle true/false Donkin Excel Programming 3 June 2nd 05 09:37 AM


All times are GMT +1. The time now is 10:30 PM.

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

About Us

"It's about Microsoft Excel"