VBA count duplicates based on column then delete duplicate, but keep one

RomanNaz

New Member
Joined
May 31, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hello! Trying to make sheet for import UPS shipments from SOR.
I have excel with orders and shipment data. 1 row = 1 shipping box
I need to find duplicates in column with order number, add count of duplicates to cell (e.g. "number of boxes"), then delete duplicate rows but keep one
Before:
Order Name Phone
1234 John 8909809
1234 John 8909809
1234 John 8909809
1248 Mike 9898799
1248 Mike 9898799
1248 Mike 9898799
1234 John 8909809

After:
Order Name Phone NumbrBoxes
1234 John 8909809 4
1248 Mike 9898799 3

I really appreciate any help you can provide
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi, according to Excel basics a VBA demonstration as a beginner starter :​
VBA Code:
Sub Demo1()
    Dim R&
        R = [A1].CurrentRegion.Rows.Count:  If R < 3 Then Beep: Exit Sub
        Application.ScreenUpdating = False
        [D1] = "Boxes #"
    With Range("A2:D" & R).Columns
        .Item(4).Formula = "=COUNTIF($A$2:$A$" & R & ",A2)"
        .Item(4).Formula = .Item(4).Value2
        .RemoveDuplicates 1, 2
    End With
        Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,720
Messages
6,126,443
Members
449,314
Latest member
MrSabo83

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