Hello,
I need some help again. I'm working with thousands of lines of data in Excel and I need to check if any value in a specified column is one of the values from a specified set of values.
I was reading a bit about arrays and thought that they may be useful here, but I never used them before and I'm not sure how to get it to work right.
I'm running a check for all rows (from 2 to my last row declared earlier) and don't know how to do a check for arrays (it's BelongsToArray now in code)
Is there a way to do a similar check, using arrays or not. I don't want to introduce too many "or" in single If statement for all numbers in my arrays or go through all rows more than once (as it would be slow).
Thank you in advance for all your tips!
I need some help again. I'm working with thousands of lines of data in Excel and I need to check if any value in a specified column is one of the values from a specified set of values.
I was reading a bit about arrays and thought that they may be useful here, but I never used them before and I'm not sure how to get it to work right.
I'm running a check for all rows (from 2 to my last row declared earlier) and don't know how to do a check for arrays (it's BelongsToArray now in code)
Code:
Dim MyArray
MyArray= Array(8182, 8183)
Dim OtherArray
OtherArray= Array(19909, 20201, 20317)
For i = 2 To lastrow
If .Cells(i,10).value [B][I]BelongsToMyArray [/I][/B]or .Cells(i,12).value [B][I]BelongsToOtherArray [/I][/B]Then
-do stuff-
End If
Next i
Is there a way to do a similar check, using arrays or not. I don't want to introduce too many "or" in single If statement for all numbers in my arrays or go through all rows more than once (as it would be slow).
Thank you in advance for all your tips!
Last edited: