I am using the following code to count the values in column "A". The values in "A" are "Blocks" of data separated by single blank cells. I need the code to evaluate each block separately (because the same entry in "A" may occur in different blocks).
Can the code be modified to achieve this?
- Code: Select all
- Code: Select all
Public Sub CreateSummary()
With CreateObject("Scripting.Dictionary")
.CompareMode = TextCompare
For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
If .Exists(Range("A" & i).Value) Then
.Item(Range("A" & i).Value) = .Item(Range("A" & i).Value) + 1
Else
.Add Range("A" & i).Value, 1
End If
Next i
Range("B1").Resize(1, 2).Value = Array("Value", "Count")
Range("B2").Resize(.Count, 2).Value = Application.Transpose(Array(.Keys, .Items))
End With
End Sub
A B C
[list] Value Count
Pistol BascLOST Pistol BascLOST 1
RobobarWON RobobarWON 2
BobbisoxLOST BobbisoxLOST 1
RobobarWON MaricoLOST 2
MaricoLOST Cloudy DawnLOST 1
MaricoLOST Farmer FrankLOST 1
Cloudy DawnLOST
Farmer FrankLOST Muir LodgeLOST 6
Bahamian CLOST 2
Muir LodgeLOST BaccalaureateLOST 2
Muir LodgeLOST GetabuzzLOST 3
Muir LodgeLOST Fennell BayWON 4
Bahamian CLOST CalafLOST 1
Bahamian CLOST
Muir LodgeLOST
Muir LodgeLOST
Muir LodgeLOST
BaccalaureateLOST
BaccalaureateLOST
GetabuzzLOST
Fennell BayWON
Fennell BayWON
GetabuzzLOST
Fennell BayWON
Fennell BayWON
CalafLOST
I'm afraid I just can't recreate the spreadsheet columns here. I hope you can understand it.
Bert