Hi guys,
So I played around with the macro i posted on the previous thread, two allow me to compare two columns of data to see if they contain the same information, and have come up with the below, which works almost flawlessly:
Sub macro_1()
Dim count
Dim i As Integer
i = 1
For count = 1 To Range("A" & Rows.count).End(xlUp).Row
'If InStr(1, Range("B" & count), Range("A" & count)) = 0 Then MsgBox "not in row " & count'
If InStr(1, Range("B" & count), Range("A" & count)) = 0 Then Cells(i, 4).Value = "N"
If InStr(1, Range("B" & count), Range("A" & count)) = 0 Then Cells(i, 4).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
If InStr(1, Range("B" & count), Range("A" & count)) = 1 Then Cells(i, 4).Value = "Y"
i = i + 1
Next count
End Sub
The idea being that it compares the two rows of data, then in the colmun to the right puts a y or n if the data is contained in both cells. I have added in some code that related to highlighting those cells with 'n' in the allow me to see it much easier. The macro works fine, however it seems that when it runs, it will sometimes highlight random cells not in column d, for example colum g etc.
Its not a major issue, but as i'm learning, im wondering if someone could maybe explain why this occurs, and how it can be fixed?
All the best
Alex
Bookmarks