I have a command that sets a variable's value in a Do until loop and I want this command to refer to a different variable each time (e.g. "datapoint1" in the first loop, "datapoint2" in the second, etc.). I tried to use a "For" loop instead of "Do Until", but that creates a problem as the times that I want the loop to be performed fluctuates a lot (the "Do Until" loop is part of a larger "For" loop).
So my question is: Is there a way to make that single command line to refer to different variables in each loop?
I have a sample of my code below for reference. Thank you all in advance for your help.
Dim datapoint(0 to 15) As Integer
Do Until hello = 1
rw = False
h = h + 1 'I have tried to use this variable to count the number of each loop.
name = ActiveCell.Offset(0, -8).Text
level = ActiveCell.Offset(0, -4).Text
If InStr(name, fullname) > 0 Then 'Checks if the line contains data for a specific name
If level = "High" Then: datapoint(h) = ActiveCell.Value ' This creates an error
Set r = ActiveCell
Do Until rw = True
Set r = r.Offset(1, 0)
If r.EntireRow.Hidden = False Then
r.Select
rw = True
End If
Loop
Else
hello = 1
End If