Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Chisisi Massri   on Jan 14 In MS Office Category.

  
Question Answered By: Tyler Thompson   on Jan 14

A macro like that should solve this problem.
Remember to change columnsToCheck to cover all your columns. I'm
covering only B, G and L. Also check the startRow variable.


Sub HighlightValues()

Dim columnsToCheck(2) As Long
Dim startRow As Long
Dim i, j, k, l As Long

columnsToCheck(0) = 2
columnsToCheck(1) = 7
columnsToCheck(2) = 12
startRow = 1

For i = 0 To UBound(columnsToCheck) Step 1
k = startRow
While Cells(k, columnsToCheck(i)) <> ""
For j = 0 To UBound(columnsToCheck) Step 1
l = startRow
While Cells(l, columnsToCheck(j)) <> ""
If Cells(k, columnsToCheck(i)).Value = Cells(l,
columnsToCheck(j)).Value Then
If (columnsToCheck(i) <> columnsToCheck(j)) Or
(columnsToCheck(i) = columnsToCheck(j) And k <> l) Then
Cells(l, columnsToCheck(j)).Interior.ColorIndex = 3
End If
End If
l = l + 1
Wend
Next j
k = k + 1
Wend
Next i


End Sub

Share: 

 
 
Didn't find what you were looking for? Find more on Highlight duplicate values of certain columns only Or get search suggestion and latest updates.


Tagged: