From the following previous image I want to create a macro that does the following:
What I want is to make a cycle that runs through the rows of my data: compare row1 of column A with row1 of column G and compare row1 of column B with row1 of column I if it is true stores the value of row1 of column H in a variable
and advance to the next row in columns G, H, I. Now make the same comparison row1 A with row 2 G and row 1 B with row2 I and if true add the value of column H above with the current column and so on.
That is to say
-
-8403 = -8403 AND 1 = 1 Then var = 9
-
-8403 = -8403 AND 1 = 1 Then var = 9 + 11
I have the following code that compares the stocks in column A in column G and it works perfectly but now I want to compare more columns.
Sub ObtenerCoincidencias()
Dim ClaveCat As Range
Dim ClaveExi As Range
Dim x As Object
Dim y As Object
Set ClaveExi = Range("A2:A18")
Set ClaveCat = Range("G2:G350")
For Each x In ClaveExi
For Each y In ClaveCat
If x = y Then
y.Interior.Color = RGB(255, 204, 0)
End If
Next y
Next x
End Sub
Some suggestions to improve my code and achieve the task I require, thank you in advance.