View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Lars-Åke Aspelin[_2_] Lars-Åke Aspelin[_2_] is offline
external usenet poster
 
Posts: 913
Default Match values in more than one column

On Wed, 6 Jan 2010 05:06:36 -0800 (PST), Richhall
wrote:

Unfortunately I am on Excel 2003 so unable to do it this way.



Then try this macro:

Sub highlight_duplicates(r As Range)
For Each c1 In r
duplicate_found = False
For Each c2 In r
If (c1.Address < c2.Address) And c1.Value = c2.Value Then
duplicate_found = True
End If
Next c2
If duplicate_found Then
c1.Interior.ColorIndex = 3
Else
c1.Interior.ColorIndex = 0
End If
Next c1
End Sub


Sub test()
highlight_duplicates ActiveSheet.Range("A1:C5")
End Sub

Hope this helps / Lars-Åke