I am trying to read a list of ids (integers) into a one dimensional array in an excel macro.
I have counted the number of IDs that will need to be inputted in a previous step therefore know what my array size needs to be. Now I want to create an array and read the values into that array. Below is the code that is giving me a "runtime error 9, subscript out of range" message on the line where I am reading the "RowID" into the array. Please let me know what I am doing incorrectly.
Notes: PD_incD is the count of ids to be read into array.
Dim AIN As Integer 'Array index
Dim PD_IncD_Array() As Variant
ReDim PD_IncD_Array(1 To PD_IncD) As Variant 'Create array for recording section IDs
AIN = 1 'Reset value
RowID = PD_1stRow 'Reset first row to begin search
Do While Not IsEmpty(Worksheets("Piping Data").Cells(RowID, 3).Value)
If Worksheets("Piping Data").Cells(RowID, 3).Value = 1 Then
PD_IncD_Array(AIN, 1) = RowID
AIN = AIN + 1
Else
RowID = RowID + 1
End If
Loop
MsgBox (PD_IncD_Array(AIN, 1))