macro to find compare cells contents from one colume to another
Posted on 2011-03-09
I am trying to write a macro that examines if the cells of one column have unique values as compared to the cells of another column. So basically I want to look at cell F1, then compare it to every cell in Column G. If it finds a duplicate value anywhere in Column G it will put "duplicate" in Cell M1, if not it will put "unique". I have started the macro and have the following:
Dim i As Integer, Finder As Variant, SearchRange As Range, c As Variant
i = 1
Do Until Selection.Value = ""
Finder = Right((Selection.Value), (Len(Selection.Value) - 7))
Set SearchRange = ActiveSheet.Columns(7)
For Each c In SearchRange
If c.Value = Finder Then
Selection.Offset(0, 7).Value = "duplicate"
Else: selections.Offset(0, 7).Value = "unique"
i = i + 1
However I keep getting a runtime error 13 - type mismatch at 'If c.Value = Finder Then'
any help sorting me out would be much appreciated. thanks.