Count certain value

elmnas

Board Regular
Joined
Feb 20, 2015
Messages
206
Hello people,

I have got a column that contains loads different order numbers like my example below:

(COLUMN A)
ORDERNR:
123
123
123
123
124
124
124
124
125
125
125
126
126
126

I need a script that make strings and loop through all numbers how many time each number been repeated
result
123= 4

next time function loops
124= 4

next time function loops
125 = 3

etc.

Could someone help me ?


Thank you in advance
 
a pivot table would list the totals for all numbers in a neat table - any reason why you are not using one ?
 
Upvote 0
I looked at original thread and do not understand. Easy to count repetitions in a column - but what do you want to do then ?
a......67
b......54
c......101
a......99

a repeats twice - then what?
 
Upvote 0
use the below code

Dim Unique As New Collection
Dim LastRow As Long
Dim A As Long
Dim Cnt As Long
Dim FirstAddress As String
Dim Msg As String
Dim c As Range
Sheets("sheet1").Select
With Worksheets(1)
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row

For A = 2 To LastRow
On Error Resume Next
Unique.add CStr(.Range("B" & A)), CStr(.Range("B" & A))
On Error GoTo 0
Next

For A = 1 To Unique.Count
With .Range("B1:B" & LastRow)
Set c = .Find(Unique(A), LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
Cnt = Cnt + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
Msg = Msg & Unique(A) & "-" & Cnt & vbCr
Cnt = 0
End If
End With
Next
End With
MsgBox Msg, vbOKOnly, "Report"
 
Upvote 0
When I run this function I dont see anything in the report. msg why?
I also replaced Sheet1 to the one we use.
 
Upvote 0

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