For Each Next; Multiple Arrays; VBA; Excel User Form;

Joined
Aug 25, 2009
Messages
2
Reaction score
0
I have a user form in Excel with several arrays of checkboxes. Some of the checkboxes are in more than one array. I have a command button on the form and I need the code to work something like this...

For Each checkbox in Array1
If checkbox.Value = True Then
Sheets("Template Sheet").Select
Sheets("Template Sheet").Copy After:=Sheets(1) 'Probable enumeration issue
Sheets("Template Sheet (2)").Select
Sheets("Template Sheet (2)").Name = checkbox.Caption
End If
Next

For Each checkbox in Array2
If checkbox.Value = True Then
Sheets("CheckboxCaption").Select
ActiveSheet.Range("E30").Select
ActiveCell.Value = checkbox.Caption
ActiveCell.Offset(1,0).Select
End If
Next

Please, ANY help is very appreciated. I am being pushed and my brain if fried.
 
Joined
Aug 25, 2009
Messages
2
Reaction score
0
Win Some; Lose Some

Dim lngIndex As Long
Dim blnArray(2) As Boolean

For lngIndex = 1 To 2
If ScopeSheetCreator.Controls("Sheet" & lngIndex).Value = True Then
Sheets("Template Sheet").Select
Sheets("Template Sheet").Copy After:=Sheets(lngIndex)
Sheets("Template Sheet (2)").Select
Sheets("Template Sheet (2)").Name = ScopeSheetCreator.Controls("Sheet" & lngIndex).Caption
ActiveSheet.Range("D1").Select


'OTHER CODE THAT WORKS

Dim genIndex As Long
Dim genArray(3) As Boolean
For genIndex = 1 To 3
If ScopeSheetCreator.Controls("GeneralItem" & genIndex).Value = True Then
ActiveSheet.Range("E30").Select
ActiveCell.Value = ScopeSheetCreator.Controls("GeneralItem" & lngIdex).Caption
ActiveCell.Offset(1, 0).Select
Next'<-- This is where I get the error "Next without For" ???
End If



End If
Next
End Sub
 

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