Identify & count multiple entries in an array

gn82

New Member
Joined
Aug 6, 2011
Messages
22
Hi everyone,

I want to automate the way in which I keep track of which people show up for the weekend hikes based on a simple entry attendance. I have a simple table as follows:
ABCDE
1Date7 Oct14 Oct21 Oct28 Oct
2ParticipantsMikeDanielleMikeDanielle
3MelissaDanDanJulie
4DanAlexandraRobertMelissa
5AlexandraMikeRaphaelMike
6RaphaelMelissa

<tbody>
</tbody>

Can you please help me obtain a simple descending attendance report like the example bellow:
Attendance: Mike (4x), Dan (3x), Melissa (3x), Alexandra (2x), Danielle (2x), Raphael (2x), Julie (1x), Robert (1x)
PS: I apologize in advance if my counting wasn't fully accurate. Also, I use MS Office 2007, if that helps in any way.

Thanks in advance.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Copy the formula in B10 across to match the list of participants. I missed Dan but you can just add him to the names in row 9.
Test1

*ABCDEFGH
1Date 7-Oct14-Oct21-Oct28-Oct***
2Participants MikeDanielleMikeDanielle***
3*MelissaDanDanJulie***
4*DanAlexandraRobertMelissa***
5*AlexandraMikeRaphaelMike***
6**RaphaelMelissa****
7********
8********
9NameAlexandraDanielleJulieMelissaMikeRaphaelRobert
10*2X2X1X3X4X2X1X

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:83px;"><col style="width:73px;"><col style="width:73px;"><col style="width:60px;"><col style="width:59px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B10=COUNTIF($B$2:$E$6,B$9)&"X"

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0
Hi,

A PivotTable can do this easily. Here are the steps:
  • Press Alt -> D -> P to bring up the Wizard
  • Select 'Multiple consolidation ranges' and click Next
  • Select 'Create a single page field for me' and click Next
  • For the 'Range:' box Select all your data (including the column headers)
  • Click Add and then click Next
  • Choose where you want to put the PivotTable and click Finish
In the resulting PivotTable:
  • Remove any automatically added fields (uncheck all the checked boxes in the field list)
  • Drag the 'Value' field to the 'Row Labels' section
  • Drag the 'Value' field again, this time to the 'Values' section
  • Click the filter drop-down next to the Row Labels header in the PivotTable, click on 'More Sort Options...', choose 'Descending (Z to A) by: Count of Value'
Notes:

 
Upvote 0
@ JoeMo - Thanks for your suggestion.
Coming back to my initial question: can all that be put in 1 descending formula so that I won't have to add each participant manually?

Copy the formula in B10 across to match the list of participants. I missed Dan but you can just add him to the names in row 9.
Test1

*ABCDEFGH
1Date7-Oct14-Oct21-Oct28-Oct***
2ParticipantsMikeDanielleMikeDanielle***
3*MelissaDanDanJulie***
4*DanAlexandraRobertMelissa***
5*AlexandraMikeRaphaelMike***
6**RaphaelMelissa****
7********
8********
9NameAlexandraDanielleJulieMelissaMikeRaphaelRobert
10*2X2X1X3X4X2X1X

<tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B10=COUNTIF($B$2:$E$6,B$9)&"X"

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0
@ JoeMo - Thanks for your suggestion.
Coming back to my initial question: can all that be put in 1 descending formula so that I won't have to add each participant manually?
Possibly, but I think you'd be better off with circledchicken's advice to go with a pivot table.
 
Upvote 0
Hello gn82. Click here to download your sample file and give it a try. Will this suit your purpose?

Cheers!
 
Upvote 0
gn82,


Sample raw data in worksheet Sheet1:


Excel Workbook
ABCDEFG
1Date7-Oct14-Oct21-Oct28-Oct
2ParticipantsMikeDanielleMikeDanielle
3MelissaDanDanJulie
4DanAlexandraRobertMelissa
5AlexandraMikeRaphaelMike
6RaphaelMelissa
7
8
9
10
Sheet1





After the macro in a new worksheet Attendance:


Excel Workbook
AB
1NameCount
2Mike4
3Dan3
4Melissa3
5Alexandra2
6Danielle2
7Raphael2
8Julie1
9Robert1
10
11
12
13
Attendance





If you add the data for the hike on Nov 2:


Excel Workbook
ABCDEFG
1Date7-Oct14-Oct21-Oct28-Oct2-Nov
2ParticipantsMikeDanielleMikeDanielleDan
3MelissaDanDanJulieAlexandra
4DanAlexandraRobertMelissaMike
5AlexandraMikeRaphaelMikeRaphael
6RaphaelMelissagn82
7hiker95
8
9
10
Sheet1





Then we get this:


Excel Workbook
AB
1NameCount
2Mike5
3Dan4
4Alexandra3
5Melissa3
6Raphael3
7Danielle2
8gn821
9hiker951
10Julie1
11Robert1
12
13
Attendance





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub GetUniques()
' hiker95, 11/30/2012
' http://www.mrexcel.com/forum/excel-questions/672289-identify-count-multiple-entries-array.html
Dim w1 As Worksheet, wA As Worksheet
Dim lr As Long, lr2 As Long, lc As Long
Dim d As Object, c As Range
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
If Not Evaluate("ISREF(Attendance!A1)") Then Worksheets.Add(After:=w1).Name = "Attendance"
Set wA = Worksheets("Attendance")
wA.UsedRange.Clear
wA.Cells(1, 1).Resize(, 2).Value = [{"Name","Count"}]
lr = w1.Cells.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False).Row
lc = w1.Cells.Find("*", , xlValues, xlWhole, xlByColumns, xlPrevious, False).Column
Set d = CreateObject("Scripting.Dictionary")
With d
  For Each c In w1.Range(w1.Cells(2, 2), w1.Cells(lr, lc))
    If c <> "" Then
      If .Exists(c.Value) Then
        .Item(c.Value) = .Item(c.Value) + 1
      Else
        .Add c.Value, 1
      End If
    End If
  Next c
  wA.Range("A2").Resize(.Count, 2).Value = WorksheetFunction.Transpose(Array(.Keys, .Items))
End With
lr2 = wA.Cells(Rows.Count, 1).End(xlUp).Row
wA.Range("A2:B" & lr2).Sort key1:=wA.Range("B2"), order1:=2, key2:=wA.Range("A2"), order2:=1
wA.Cells.EntireColumn.AutoFit
wA.Activate
Application.ScreenUpdating = True
End Sub


Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


Then run the GetUniques macro.
 
Upvote 0
@ mump - Thanks for the sample. Looks nice though I was hoping for a simple way to get just the report without having to perform any additional tasks. At the moment I simply adjust the report at the end of every weekend based on who was present in the last hiking trip. It is a manual process and prone to error but it is quite fast so the only significant improvement would have been to get the report directly.

Hello gn82. Click here to download your sample file and give it a try. Will this suit your purpose?

Cheers!
 
Upvote 0

Forum statistics

Threads
1,215,203
Messages
6,123,627
Members
449,109
Latest member
Sebas8956

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