Count the number of times a name appears

steven811

New Member
Joined
Jul 14, 2015
Messages
20
Hi All

we are wanting to calculate the lifetime value of a customer. I have history table of 3 columns (10k of entries) with the customer name appearing every time they have ordered over the past two years. Is there a way I can count the number of times a name appears in a list. Ideally using the names in the list as the index.

Example of the date here. You can see that N2OLIMIT appears four times.

I'd like to add another column that shows the number of times a customer has ordered. Then I can sort and use this information.

03/01/2017AMIENJOM22.04
03/01/2017N20LIMIT605.50
03/01/2017JKPLUMBI146.19
03/01/2017N20LIMIT217.00
03/01/2017N20LIMIT237.43
03/01/2017GBSCONSU276.47
03/01/2017DESILVAT46.98
03/01/2017CAMBRIAN71.05
03/01/2017ACACIARA38.64
03/01/2017KRULIVEL166.50
03/01/2017N20LIMIT1498.50
03/01/2017UNIVERS21209.35
03/01/2017PROCUREM235.50

<tbody>
</tbody>

Thanks in advance

Steven811
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You can use a pivot table. You can watch any video to create pivot table, for example:

https://www.youtube.com/watch?v=sJqmqKBKwGs


Excel Workbook
ABCDEF
1DATENAMEVALUE
203/01/2017AMIENJOM22.04Rtulos de filaCuenta de VALUE
303/01/2017N20LIMIT605.5ACACIARA1
403/01/2017JKPLUMBI146.19AMIENJOM1
503/01/2017N20LIMIT217CAMBRIAN1
603/01/2017N20LIMIT237.43DESILVAT1
703/01/2017GBSCONSU276.47GBSCONSU1
803/01/2017DESILVAT46.98JKPLUMBI1
903/01/2017CAMBRIAN71.05KRULIVEL1
1003/01/2017ACACIARA38.64N20LIMIT4
1103/01/2017KRULIVEL166.5PROCUREM1
1203/01/2017N20LIMIT1498.5UNIVERS21
1303/01/2017UNIVERS21209.35Total general13
1403/01/2017PROCUREM235.5
Hoja2
 
Upvote 0
Assuming your data is in "Sheet1", columns A:C, starting in row 2, try this macro:
Code:
Sub steven()
    Application.ScreenUpdating = False
    Dim ws1 As Worksheet, i As Long, v1, item As Variant, rngList As Object
    Set rngList = CreateObject("Scripting.Dictionary")
    Set ws1 = Sheets("Sheet1")
    v1 = ws1.Range("B2", ws1.Range("B" & Rows.Count).End(xlUp)).Value
    For i = LBound(v1) To UBound(v1, 1)
        If Not rngList.Exists(v1(i, 1)) Then
            rngList.Add v1(i, 1), Nothing
        End If
    Next i
    For Each item In rngList
        Cells(Rows.Count, "E").End(xlUp).Offset(1, 0) = item
        Cells(Rows.Count, "F").End(xlUp).Offset(1, 0) = WorksheetFunction.CountIf(Range("B:B"), item)
    Next item
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi,

You didn't explain How you want the results, and you didn't show any sample of results, so maybe this:


Book1
ABCD
13/1/2017AMIENJOM22.041
23/1/2017N20LIMIT605.5
33/1/2017JKPLUMBI146.191
43/1/2017N20LIMIT217
53/1/2017N20LIMIT237.43
63/1/2017GBSCONSU276.471
73/1/2017DESILVAT46.981
83/1/2017CAMBRIAN71.051
93/1/2017ACACIARA38.641
103/1/2017KRULIVEL166.51
113/1/2017N20LIMIT1498.54
123/1/2017UNIVERS21209.351
133/1/2017PROCUREM235.51
Sheet637
Cell Formulas
RangeFormula
D1=IF(COUNTIF(B$1:B1,B1)=COUNTIF(B$1:B$13,B1),COUNTIF(B$1:B1,B1),"")


formula copied down.
 
Upvote 0

Forum statistics

Threads
1,215,332
Messages
6,124,314
Members
449,153
Latest member
JazzSingerNL

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