Counting number of Times "name" appears across multiple sheets

underpar

New Member
Joined
Jan 26, 2005
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
Hello:
This is a tough question to verbalize but I'll try my best. I will have a workbook with multiple sheets...one for each day. The sheets will show the names of people visiting a website. What I'm trying to do, is have a count of the number of times each "name" hit the website, but I won't know the names in advance. Maybe the question will be clearer after looking at the photos attached.

DAY 1 Sheet: shows the names (which I don't know in advance) who visited the website.
DAY 2 Sheet: shows the names (which I don't know in advance) who visited the website. It's the same people as Day 1.
DAY 3 Sheet: shows the names (which I don't know in advance) who visited the website.This time, 2 names are the same as previous days but one is different.
SUMMARY Sheet: Is there a way to show each name and the number of times they appear in the "day sheets". Since I don't know the names in advance, I can't populate the Summary Sheet with names.

Sorry for the rambling and I appreciate your help.
Cheers!
 

Attachments

  • Day 1.jpg
    Day 1.jpg
    70.9 KB · Views: 17
  • day 2.jpg
    day 2.jpg
    69.7 KB · Views: 17
  • day 3.jpg
    day 3.jpg
    71.4 KB · Views: 13
  • summary.jpg
    summary.jpg
    61.3 KB · Views: 12
Got it. Change this line:

If s.Name Like "Day *" Then

to

If LCase(s.Name) Like "day *" Then

I was checking for upper case "Day 1", and your sheets were named "day 1". The line I changed will now check for either.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi Eric: This is AWESOME and does exactly what I need. Thank you very much for the work you put into this and your prompt replies!! (y)
 
Upvote 0
Glad it works for you! Thanks for the feedback! :cool:

Hi Eric:
Could I ask you for one more version of the macro? I promise, this will be the last request :)!
This time, the sheet will be setup the same way with "day 1", "day 2", etc and a summary sheet.
The change will be that the names are 4 across in the format of "last name, first name".
The summary sheet will be the same as the previous macro....just a count of how many times each name appeared.
If you have some time to have a look, I'd sure appreciate it.

Cheers,
Mike
 

Attachments

  • 4 names wide (Medium).jpg
    4 names wide (Medium).jpg
    173.4 KB · Views: 6
Upvote 0
Try:

Rich (BB code):
Sub CountNames2()
Dim d As Object, s As Worksheet, ar1 As Variant, i As Long, c As Long
Dim d1 As Variant, d2 As Variant, op() As Variant, lr As Long

    Set d = CreateObject("Scripting.Dictionary")
    For Each s In Worksheets
        If LCase(s.Name) Like "day *" Then
            For c = 2 To 5
                lr = s.Cells(Rows.Count, c).End(xlUp).Row
                Select Case lr
                    Case 1, 2
                    Case 3
                        ar1 = s.Range(s.Cells(3, c), s.Cells(lr, c)).Value
                        d(LCase(Trim(ar1))) = d(LCase(Trim(ar1))) + 1
                    Case Else
                        ar1 = s.Range(s.Cells(3, c), s.Cells(lr, c)).Value
                        For i = 1 To UBound(ar1)
                            d(LCase(Trim(ar1(i, 1)))) = d(LCase(Trim(ar1(i, 1)))) + 1
                        Next i
                End Select
            Next c
        End If
    Next s
   
    ReDim op(1 To d.Count, 1 To 2)
    d1 = d.keys
    d2 = d.items
    For i = 0 To d.Count - 1
        op(i + 1, 1) = WorksheetFunction.Proper(d1(i))
        op(i + 1, 2) = d2(i)
    Next i
    Sheets("Summary").Range("B2:C2") = Array("Name", "Count")
    Sheets("Summary").Range("B3").Resize(d.Count, 2) = op
   
End Sub

In my testing, I ran into cases where it counted the same name as different, just because of a stray space, or capitalization difference. So I added the parts in red to handle that. If that's not an issue for you, or if you don't like the way Proper capitalizes the results, then just remove the characters in red.
 
Upvote 0
In my testing, I ran into cases where it counted the same name as different, just because of a stray space, or capitalization difference
Hi Eric:
Once again, I have to say WOW and thank you. It's perfect!!!
Cheers and all the best,
Mike
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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