This question is slightly different from the existing questions on this site listed here, here & here.
I want to write a UDF in Excel VBA (and not use any existing VBA Functions) to loop thru two ranges simultaneously at same level (1 to 1) and check if the two values match.
Public Function compare(r1 As Range, r2 As Range) As Integer
Dim i
For Each cell In r1
if cell.Value = 'value from r2 at same range level, 1 to 1 compare
i = i + 1
End If
Next cell
compare = i
End Function
In this UDF it takes in two ranges as input. Assume they are single column and equal rows for simplicity. Now using a For Each cell in Range
loop I wish to compare the two ranges at same cell level. Is this possible?
Would I need to create a Nested For and in every inner For, skips those many cells to match the cells of Outer For?