Count how many times a postcode appears

mason001

New Member
Joined
Dec 6, 2017
Messages
9
Hi there, I've been given a spread and asked to work out how many times the same postcodes appear within the spread.

For example... If I was given the postcodes below, I'd like to have a function to count of how many times they appear... so RH140HW is on there 3 times, RH204NU 2 times, etc.; so I know what is the postcode that appears most-to-least. I've got over 8500 postcodes to sort through and count!

[TABLE="width: 89"]
<tbody>[TR]
[TD]PO7 6PR
RH204NU
RH140HW
RH140HW
RH138BE
BN435NG
PO200DP
RH204NU
RH140HW
RH138BE
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Any help is much appreciated.

Thanks[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 89"]
<tbody>[TR]
[TD][/TD]
[/TR]
[TR]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

Try this formula. It will determine if the postcode on the row appears for the first time in the list and if so count how many times occurs in the complete list.


Book1
AB
1codeUnique Count
2PO7 6PR1
3RH204NU2
4RH140HW3
5RH140HW
6RH138BE2
7BN435NG1
8PO200DP1
9RH204NU
10RH140HW
11RH138BE
Sheet1
Cell Formulas
RangeFormula
B2=IF(COUNTIF($A$2:A2,A2)=1,COUNTIF($A$2:$A$11,A2),"")
 
Upvote 0
I've got over 8500 postcodes to sort through and count!

Hi, welcome to the forum!

Another option would be to use a pivot table, you would drag the post code field to both the "rows area" and the "values area".
 
Upvote 0
I would use this vba code:

Assuming your list of postal codes are in Column "A"
The unique postal codes will be put in column "B"
And the number of times each postal code is found will be put in column "C" next to the unique postal code.
Code:
Sub Count_Me()
'Modified 12-6-17 6:05 AM EST
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Dim Lastrowb As Long
Range(Cells(1, 1), Cells(Lastrow, 1)).Copy Cells(1, 2)
Lastrowb = Cells(Rows.Count, "B").End(xlUp).Row
Range(Cells(1, 2), Cells(Lastrowb, 2)).RemoveDuplicates 1, xlNo
Lastrowb = Cells(Rows.Count, "B").End(xlUp).Row
    For i = 1 To Lastrowb
        Cells(i, "C").Value = WorksheetFunction.CountIf(Range("A1:A" & Lastrow), Cells(i, 2).Value)
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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