I am attempting to check if any value in a dynamic array of size "i" by one is greater than zero where "i" is a user input. If false, the value of the first element in the array would show in the next column. If true, the values of the array update by essentially moving down one element. I believe I have found answers for this question in java here, but haven't had any luck finding it in vba. I believe this could be done with a for loop as done here, but would like something more efficient if it exists. Since I do not know any syntax which may work the code hangs at "If any x > 0 Then"
Dim i, z, u As Integer
Dim fir As Integer
Dim las As Integer
Dim n As Long
Dim x As Variant
'SET VALUE OF ROWS FOR ARRAY
i = Worksheets("INPUTS").Range("C6").Value
Set s = Worksheets("DATA")
'FIND LAST VALUE IN DATA
n = s.Cells(s.Rows.Count, "A").End(xlUp).Row
'BEGIN LOOP THROUGH DATA SET
For z = 1 To n
'SET/RESET RANGE TO CHECK FOR CONSECUTIVE VALUES LESS THAN ZERO
fir = z
las = i + z - 1
x = (s.Range("C" & fir, "C" & las).Value)
u = s.Range("C" & UBound(x)).Value
If any x > 0 Then
Else: s.Cells(4, z) = x(1, 1).Value
End If
Next z
I'm a beginner and new to the forum so feel free to tear me a new one on anything against best practices relating to the code or the question, thank you.