I need help avoiding duplicates

dadams25

New Member
Joined
Oct 12, 2011
Messages
23
i have a workbook that has lots of the identical sheet copied and renamed to employees for accountability purposes. i put an order number in column "L" on all of the sheets. how can i go about getting the word "duplicate" to populate in column "M" on the same row when the same order number is already in the workbook.

putting all of the data on the same sheet instead of separate sheets is not an option. some have told me that i would need to use a macro but i do not know how to write a macro.

anyone able to help me out of this issue?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Based on my understanding:
Assume you have 3 sheets (named Sheet 1, Sheet 2, Sheet3) and data starts at cell L2
Enter this formula in cell M2 and copy down

Code:
=IF(COUNTIF(Sheet1!L:L,L2)+COUNTIF(Sheet2!L:L,L2)+COUNTIF(Sheet3!L:L,L2)>1,"Duplicate","")

If you have more sheets will need to add more countif
 
Upvote 0
Place the following code in a VBA Module and execute. It will mark the Duplicate Orders from Column "L" with the "Dup" tag in column "M". It will also provide a number representing the number of times this Order number has been encoundered.

Not that the first occurance of the Order Number is not maked as a "Dup"

Code:
Option Explicit
Type RecType
    OrderNumber As String
    Cnt As Long
End Type
Dim Rec() As RecType
Function FindDups()
    Dim ws As Worksheet
    Dim wsNo As Integer
    Dim RowNo As Long
    Dim Idx As Long
    
    ReDim Rec(0)
    
    For wsNo = 1 To ThisWorkbook.Worksheets.Count
        Set ws = ThisWorkbook.Worksheets(wsNo)
    
        For RowNo = 2 To ws.UsedRange.Rows.Count
            Idx = FindOrdNoIdx(ws.Cells(RowNo, 12)) 'Column 'L' is 12
            If Rec(Idx).Cnt > 1 Then
                ws.Cells(RowNo, 13) = "Dup " & Rec(Idx).Cnt
            Else
                ws.Cells(RowNo, 13) = ""
            End If
                
        Next RowNo
        
    Next
End Function
Function FindOrdNoIdx(OrderNo As String) As Long
    Dim I As Long
    For I = 1 To UBound(Rec)
        If Rec(I).OrderNumber = OrderNo Then
            FindOrdNoIdx = I
            Rec(I).Cnt = Rec(I).Cnt + 1
            Exit Function
        End If
    Next I
        
    ReDim Preserve Rec(I)
    Rec(I).OrderNumber = OrderNo
    Rec(I).Cnt = 1
    FindOrdNoIdx = I
End Function
 
Upvote 0

Forum statistics

Threads
1,222,102
Messages
6,163,940
Members
451,866
Latest member
cradd64

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