Sum duplicate names in a column VBA

job432

New Member
Joined
Jun 18, 2015
Messages
9
Hi everyone,

I have a single column of data in Column A that looks like this:

Joe
Joe
Joe
John
John
Josh
Josh
Josh
Josh

Can someone please provide me with code that would sum the number of Joes, Johns, and Joshs and put the sum for each name in the adjacement column. Thank you in advance! Huge help.. I have 5000 rows of names
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Thank you for the quick response @FryGirl. I am not familiar with pivot tables. Would you mind instructing me, please?
 
Upvote 0
If you still want to use a macro, consider this one (it assumes you have nothing in Columns B or C)...
Code:
Sub CountNamesInColumnA()
  Dim LastRowA As Long, LastRowB As Long
  Application.ScreenUpdating = False
  Columns("B:C").Clear
  Range("A1", Cells(Rows.Count, "A").End(xlUp)).Copy Range("B1")
  Columns("B").RemoveDuplicates 1, xlNo
  LastRowA = Cells(Rows.Count, "A").End(xlUp).Row
  LastRowB = Cells(Rows.Count, "B").End(xlUp).Row
  With Range("C1:C" & LastRowB)
    .Formula = "=COUNTIF(A$1:A$" & LastRowA & ",B1)"
    .Value = .Value
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,705
Members
449,048
Latest member
81jamesacct

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