VBA - Programming basics Looping

Lambel
Lambel used Ask the Experts™
on
I have a loop to run though the selections in a listbox and load them into an array.  I need to also add to the array two more items that are not part of the list box.  They are check boxes on a form, and if selected, they need to be added to the array.  I tried creating a loop based on the number of items selected from the list box, then adding two more iterations on to it, but I am getting a type mismatch error.  Can someone suggest a fix for this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Retired
Top Expert 2012
Commented:
If the process in the loop is complex, put it in a Sub. The call it in the loop and a couple of extra times.


Dim i As Integer
For i = 0 To ListBox1.ListCount - 1
    If ListBox1.List(i).Selected Then
     Call MyProcess(ListBox1.List(i).Value)
    End If
Next i
If CheckBox1.Value Then
    Call MyProcess(CheckBox1.Caption)
End If
If CheckBox2.Value Then
    Call MyProcess(CheckBox2.Caption)
End If

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial