I am trying to fill a dynamic array with the row indexes from a search function. So far I have created a loop that introduces a leading or trailing 0 to fill the array. I would like to fill the array without the 0 but my current code keeps giving me a 'subscript out of range' error. This should be a easy fix, I just dont understand VBA enough to fix it myself. All help appreciated!
Code:
Dim Results1() As Variant
Dim TextBox1 As Long
Dim FindRange1 As Range
Dim Find1 As Range
Dim i1 As Long
ReDim Results1(1)
TextBox1 = ILsearch.TextBox1.Value
If ILsearch.P1B1.Value = True Then
For Each Find1 In FindRange1
If (Find1.Value < TextBox1) And (Find1.Value > 0) Then
Results1(i1) = Find1.Row
i1 = i1 + 1
ReDim Preserve Results1(i1)
End If
Next Find1
End If