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.

[TABLE="width: 227"]
<tbody>[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]AMIENJOM[/TD]
[TD="colspan: 2"]22.04[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]N20LIMIT[/TD]
[TD="colspan: 2"]605.50[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]JKPLUMBI[/TD]
[TD="colspan: 2"]146.19[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]N20LIMIT[/TD]
[TD="colspan: 2"]217.00[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]N20LIMIT[/TD]
[TD="colspan: 2"]237.43[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]GBSCONSU[/TD]
[TD="colspan: 2"]276.47[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]DESILVAT[/TD]
[TD="colspan: 2"]46.98[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]CAMBRIAN[/TD]
[TD="colspan: 2"]71.05[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]ACACIARA[/TD]
[TD="colspan: 2"]38.64[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]KRULIVEL[/TD]
[TD="colspan: 2"]166.50[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]N20LIMIT[/TD]
[TD="colspan: 2"]1498.50[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]UNIVERS2[/TD]
[TD="colspan: 2"]1209.35[/TD]
[/TR]
[TR]
[TD]03/01/2017[/TD]
[TD="colspan: 2"]PROCUREM[/TD]
[TD="colspan: 2"]235.50[/TD]
[/TR]
</tbody>[/TABLE]

Thanks in advance

Steven811
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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