Preventing Duplicates

dooz1990

New Member
Joined
Apr 15, 2013
Messages
1
Hi,

Is there anyway to stop the below code producing duplicates?

Thanks

Code:
If ComboBox1.Value = "Product" Then
'USER BREAKDOWN
userLR = Range("J" & Rows.Count).End(xlUp).Row
userLC = Cells(1, Columns.Count).End(xlToLeft).Column
Columns("K").Insert
For useri = userLR To 1 Step -1
    With Range("J" & useri)
        If InStr(.Value, "; ") = 0 Then
            .Value = .Value
        Else
            userX = Split(.Value, "; ")
            .Offset(1).Resize(UBound(userX)).EntireRow.Insert
            .Resize(UBound(userX) - LBound(userX) + 1).Value = Application.Transpose(userX)
        End If
    End With
Next useri
Columns("K").Delete
userLR = Range("J" & Rows.Count).End(xlUp).Row
With Range(Cells(1, 1), Cells(userLR, userLC))
    On Error Resume Next
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    On Error GoTo 0
    .Value = .Value
End With
'Product Breakdown
LR = Range("C" & Rows.Count).End(xlUp).Row
LC = Cells(1, Columns.Count).End(xlToLeft).Column
Columns("D").Insert
For i = LR To 1 Step -1
    With Range("C" & i)
        If InStr(.Value, "; ") = 0 Then
            .Value = .Value
        Else
            X = Split(.Value, "; ")
            .Offset(1).Resize(UBound(X)).EntireRow.Insert
            .Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
        End If
    End With
Next i
Columns("D").Delete
LR = Range("C" & Rows.Count).End(xlUp).Row
With Range(Cells(1, 1), Cells(LR, LC))
    On Error Resume Next
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    On Error GoTo 0
    .Value = .Value
End With
End IF
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,203,686
Messages
6,056,737
Members
444,888
Latest member
Babi_mn

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