I am trying to find a way to get this like
Dim MyArray(1 To 1893) As Integer
work dynamic currently I am unable to do so and always need to type number which in fact is max(TAS_ID) Any help will be appreciated, I can not find a way to define array from 1 to n.. or find other method to achieve same effect.
Sub Moving_Data()
Dim i, j, LastRow, tempID As Integer
Dim TAS_ID As Integer
Dim k As Boolean
LastRow = Cells(Rows.Count, 4).End(xlUp).Row 'last row
For i = 1 To LastRow
Cells(i, 1) = i
Next i
TAS_ID = 1
i = 2
k = True
Dim MyArray(1 To 1893) As Integer ' add max zone number!
'Dim MyArray(1 To max(TAS_ID)) As Integer ??????
Do While k = True
Do While Cells(i + 1, 2) = ""
If i > LastRow Then
Exit Do
End If
Cells(i, 2) = TAS_ID
i = i + 1
Loop
j = i
MyArray(TAS_ID) = j - 1
Cells(2, 14) = j
TAS_ID = Cells(i + 1, 2)
If i > LastRow Then
k = False
Exit Do
End If
j = i + 2
i = j
Loop
For i = 1 To UBound(MyArray)
Cells(1 + i, 11).Value = MyArray(i)
Cells(1 + i, "J") = i
Next i
End Sub