Sort, List, and Count repetitions of values within a range

M0Dark

New Member
Joined
Feb 19, 2014
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a range of cells (P2:AZ50) which contain String values and blank cells. What I want to do is get a list of all the discrete values out of that range in column BA and a count off the occurrences in column BB.
The data changes with cell values being changed / replaced with blanks etc, but not frequently enough that a manual macro button (for example) to recompile the list & count would be a problem.
Please advise the best way to accomplish this.

Many thanks.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:
VBA Code:
Sub test1()
Dim x, va
Dim d As Object

Set d = CreateObject("scripting.dictionary")
d.CompareMode = vbTextCompare

va = Range("P2:AZ50")
    For Each x In va
        d(x) = d(x) + 1
    Next

If d.Exists("") Then d.Remove ""

'put the result in col BA:
Range("BA2").Resize(d.Count, 2) = Application.Transpose(Array(d.Keys, d.Items))

End Sub
 
Upvote 0
With a formula.
In BA2
Excel Formula:
=UNIQUE(TOCOL(P2:AZ50,1))
and in BB2
Excel Formula:
=COUNTIFS(P2:AZ50,BB2#)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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