E
Eugene Gerber
I am trying to use the Redim statement to create a growing 2-dimensional
list. I get the following error the second time I try to Redim:
Run-time error '9':
Subscript out of range.
The code is as follows:
Dim List() As String
Dim ListCount As Integer
ListCount = 0
For Each item In Workbooks("Master
Pricelist.xls").Worksheets("Pricelist").Range("DataCategory")
If Target.Value = item.Value Then
If ListCount = 0 Then
ListCount = ListCount + 1
ReDim Preserve List(ListCount, 1)
List(ListCount, 1) = item.Range("B1").Value
ElseIf NotInList(item.Range("B1").Value, List,
ListCount, 1) Then
ListCount = ListCount + 1
ReDim Preserve List(ListCount, 1)
*****This line give the error
List(ListCount, 1) = item.Range("B1").Value
End If
End If
Why does the Redim statement work the first time but not the second time?
list. I get the following error the second time I try to Redim:
Run-time error '9':
Subscript out of range.
The code is as follows:
Dim List() As String
Dim ListCount As Integer
ListCount = 0
For Each item In Workbooks("Master
Pricelist.xls").Worksheets("Pricelist").Range("DataCategory")
If Target.Value = item.Value Then
If ListCount = 0 Then
ListCount = ListCount + 1
ReDim Preserve List(ListCount, 1)
List(ListCount, 1) = item.Range("B1").Value
ElseIf NotInList(item.Range("B1").Value, List,
ListCount, 1) Then
ListCount = ListCount + 1
ReDim Preserve List(ListCount, 1)
*****This line give the error
List(ListCount, 1) = item.Range("B1").Value
End If
End If
Why does the Redim statement work the first time but not the second time?