S
shivboy
Hi,
I'm using a userform to capture data and there on display them in
various cells in a sheet. For storing the data before displaying in the
cells, I am using a multidimensional array. Now, the problem I am facing
is that I have a combobox and a listbox whose values I want to keep on
adding into the multidimensional array till the user clicks the submit
button. The code I am using is :
Code:
--------------------
Dim arr() As String
Dim oName As String
Dim oJob As String
Dim cName As Integer
cName = lbColNames.ListCount
oName = txtColName.Value
oJob = cbJob.Value
If cbJob.Value = "" Then
MsgBox "Please select a Job."
cbJob.SetFocus
Else
lbColNames.AddItem (oName)
ReDim Preserve arr(cName, cName)
arr(cName, cName) = oName
arr(cName, cName + 1) = oJob
End If
--------------------
But this generates an error "Subscript out of range". What wrong am I
doing here? And how to insert values from 2 different controls into one
multidimensional array? Please help.
Peace,
Shivboy
I'm using a userform to capture data and there on display them in
various cells in a sheet. For storing the data before displaying in the
cells, I am using a multidimensional array. Now, the problem I am facing
is that I have a combobox and a listbox whose values I want to keep on
adding into the multidimensional array till the user clicks the submit
button. The code I am using is :
Code:
--------------------
Dim arr() As String
Dim oName As String
Dim oJob As String
Dim cName As Integer
cName = lbColNames.ListCount
oName = txtColName.Value
oJob = cbJob.Value
If cbJob.Value = "" Then
MsgBox "Please select a Job."
cbJob.SetFocus
Else
lbColNames.AddItem (oName)
ReDim Preserve arr(cName, cName)
arr(cName, cName) = oName
arr(cName, cName + 1) = oJob
End If
--------------------
But this generates an error "Subscript out of range". What wrong am I
doing here? And how to insert values from 2 different controls into one
multidimensional array? Please help.
Peace,
Shivboy