J
John Michl
I have a simple form that allows the user to select items from a list
box. I want to store those items in an array to be used in some other
user forms. I'm having a problem testing this process.
1) Question: This is a two column list box. Can I store both columns
in my array or only the bound column? (I'm assuming the later and that
is why my code below trys to store a value from the worksheet.
2) The MsgBox at the bottom generates a Data type mismatch error. I
haven't worked with arrays recently so I'm sure it is something simple.
Help.
Note: The array variable arrProcess is Public and declared in the
module that opens the form.
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub cmdProcessesPicked_Click()
cnt = 0
For i = 0 To lstProcess.ListCount - 1
If lstProcess.Selected(i) Then _
cnt = cnt + 1
Next i
ReDim arrProcess(1 To cnt, 1 To cnt)
ar = 1
For i = 1 To lstProcess.ListCount - 1
If lstProcess.Selected(i) Then
arrProcess(ar, 1) = Range("OptionsFull_list").Offset(i - 1,
1)
arrProcess(ar, 2) = lstProcess.Selected(i)
ar = ar + 1
End If
Next i
For ar = 1 To UBound(arrProcess)
MsgBox arrProcess(ar, 1) & " " & arrProcess(ar, 2) 'HERE IS
THE ERROR
Next ar
Unload frmProcessList
End Sub
box. I want to store those items in an array to be used in some other
user forms. I'm having a problem testing this process.
1) Question: This is a two column list box. Can I store both columns
in my array or only the bound column? (I'm assuming the later and that
is why my code below trys to store a value from the worksheet.
2) The MsgBox at the bottom generates a Data type mismatch error. I
haven't worked with arrays recently so I'm sure it is something simple.
Help.
Note: The array variable arrProcess is Public and declared in the
module that opens the form.
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub cmdProcessesPicked_Click()
cnt = 0
For i = 0 To lstProcess.ListCount - 1
If lstProcess.Selected(i) Then _
cnt = cnt + 1
Next i
ReDim arrProcess(1 To cnt, 1 To cnt)
ar = 1
For i = 1 To lstProcess.ListCount - 1
If lstProcess.Selected(i) Then
arrProcess(ar, 1) = Range("OptionsFull_list").Offset(i - 1,
1)
arrProcess(ar, 2) = lstProcess.Selected(i)
ar = ar + 1
End If
Next i
For ar = 1 To UBound(arrProcess)
MsgBox arrProcess(ar, 1) & " " & arrProcess(ar, 2) 'HERE IS
THE ERROR
Next ar
Unload frmProcessList
End Sub