Conditional format formula to look for duplicates in multiple columns

sonosite

New Member
Joined
Nov 24, 2014
Messages
15
I am using excel for making out a shift schedule for my company. How do I create a conditional format formula to look for duplicate initials in multiple columns and to repeat the assessment independently for many more rows?

Additionally, the formula would only look at the first 2 characters in a cell to check for duplication.


Example of data


Site1 Site2 Site3 Site4 Site5
1/1/2015 AA BB CC DD EE
1/2/2015 BB CC BB AA EE
1/3/2015 CC CC CC BB AA
1/4/2015 BB CC BB-t AA EE


First row has unique initials of AA to EE. There is no error with this row.
Second row has duplicated BB in two columns that I want the formula to highlight.
Third row has duplicated CC in three columns that I want the formula to highlight.
Fourth row has duplicated BB in two columns when you look at the first two characters in the cell that I want the formula to highlight.


Since this is a day by day basis, creating a conditional formating for each row individually would be unrealistic. The formula needs to look at every single row independently in the spreadsheet.

Thanks.


 
Again, thank you! This will help me complete the shift schedule without duplication.

Another question. After I finish the shift schedules within excel, I have to start "data mining" the spreadsheet. I am not sure of the best approach and wanted to get your expert opinion of the best strategy. Is there a way to extract data based on the initials (first 2 characters in a cell only).

So for example, here is an exampled finished schedule



ABCDE
1Site1Site2Site3
21/1/2015AABB CC
31/2/2015BBAA CC
41/3/2015AACC BB
51/4/2015DD-rBB AA
61/5/2015DDAA BB-t

<colgroup><col style="font-weight: bold; width: 30px;"><col style="width: 62px;"><col style="width: 56px;"><col style="width: 56px;"><col style="width: 56px;"></colgroup><tbody>
</tbody>


I would like to generate a new worksheet/spreadsheet that summarizes something as follows:

ABCD
1AABBCCDD
21/1/2015, Site11/1/2015, Site21/1/2015, Site31/4/2015, Site1
31/2/2015, Site21/2/2015, Site11/2/2015, Site31/5/2015, Site1
41/3/2015, Site11/3/2015, Site31/3/2015, Site2
51/4/2015, Site31/4/2015, Site2
61/5/2015, Site21/5/2015, Site3

<colgroup><col style="width: 49px"><col width="100"><col width="100"><col width="100"><col width="100"></colgroup><tbody>
</tbody>
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe this macro

Assumes
Data in Sheet1
Arranged data in Sheet2

Code:
Sub aTest()
    Dim dict As Object
    Dim lastRow As Long, lastCol As Long, rngData As Variant
    Dim i As Long, j As Long
    Dim spl As Variant, v As Variant, col As Long
    
    Set dict = CreateObject("Scripting.Dictionary")
    dict.CompareMode = vbTextCompare
    
    With Sheets("Sheet1") '<--Data sheet
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
        rngData = Range(.Cells(1, 1), .Cells(lastRow, lastCol)).Value
    End With
        
    For i = 2 To UBound(rngData, 1)
        For j = 2 To UBound(rngData, 2)
            dict.Item(Left(rngData(i, j), 2)) = _
            dict.Item(Left(rngData(i, j), 2)) & rngData(i, 1) & ", " & rngData(1, j) & ";"
        Next j
    Next i
      
    With Sheets("Sheet2") '<--Destination sheet
        .Range("A1").Resize(, dict.Count).Value = dict.keys
        For Each v In dict.keys
            col = col + 1
            spl = Split(dict(v), ";")
            .Cells(2, col).Resize(UBound(spl, 1) + 1).Value = Application.Transpose(spl)
        Next v
        
        .Columns(1).Resize(, dict.Count).AutoFit
    End With
    
End Sub

M.
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,576
Members
449,173
Latest member
Kon123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top