Hello.
Table A1:Hx (x is a small number, so I can just set it to 50; ideally I'd like it so it only checks up to the last non-empty row) with a bunch of numbers.
I want a VBA that checks if the values in a certain row have a certain relation with values of any of the subsequent rows. It's a simple "loop/next" thing, but I'm just about to throw my computer out the window trying to figure out how. This is the one I have written so far:
What I need is something like "Else x=x+1, then do until the condition is true". Can't figure it out. Right now the script, I think, can only give a "true" value if the row immediately after the one examined meets the condition, but I can't make it "go find if another row further down below meets the condition" before moving on to checking a match for the next row.
Table A1:Hx (x is a small number, so I can just set it to 50; ideally I'd like it so it only checks up to the last non-empty row) with a bunch of numbers.
I want a VBA that checks if the values in a certain row have a certain relation with values of any of the subsequent rows. It's a simple "loop/next" thing, but I'm just about to throw my computer out the window trying to figure out how. This is the one I have written so far:
VBA Code:
Dim lr As Long
Dim i As Long, x As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To 50
x = i + 1
If Cells(i, 5).Value > Cells(x, 5).Value And Cells(i, 7).Value < Cells(x, 7).Value And Cells(i, 6).Value > Cells(x, 6).Value And Cells(i, 8).Value < Cells(x, 8).Value Then
Cells(i, 15).Value = "found"
End If
Next i
What I need is something like "Else x=x+1, then do until the condition is true". Can't figure it out. Right now the script, I think, can only give a "true" value if the row immediately after the one examined meets the condition, but I can't make it "go find if another row further down below meets the condition" before moving on to checking a match for the next row.
Last edited by a moderator: