Separate Column Inputting Pivot Table Rows Based On "/" Delimiter

whereswaller

New Member
Joined
Aug 27, 2013
Messages
12
Hi,
I am trying to create a table that summarises the number of times a name appears in a range (in this case an entire column, A:A) that has delimiter (in this case a forward slash) structured data.


Example dataset

Tiger Woods / Greg Norman
Greg Norman
Tiger Woods / Ernie Els
Ernie Els / Greg Norman / Tiger Woods

<tbody>
</tbody>

Example desired output
Greg Norman3
Tiger Woods3
Ernie Els2

<tbody>
</tbody>


Is there any way I can achieve this?

Note, the names in the dataset can change so I would like to avoid hardcoding the names and simply using a COUNTIF function to achieve the output.

Many thanks for any help you can provide,
James
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
if you are able to use PowerQuery (Get&Transform) you can try

Column1Column1Count
Tiger Woods / Greg NormanTiger Woods
3​
Greg NormanGreg Norman
3​
Tiger Woods / Ernie ElsErnie Els
2​
Ernie Els / Greg Norman / Tiger Woods

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Column1", Splitter.SplitTextByDelimiter(" / ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Column1"}, {{"Count", each Table.RowCount(_), type number}})
in
    #"Grouped Rows"[/SIZE]
 
Upvote 0
Here is a macro that should do what you want (source assumed to start at cell A1, output goes to Columns B and C)...
Code:
[table="width: 500"]
[tr]
	[td]Sub NameCount()
  Dim X As Long, Data As Variant
  Data = Split(Replace(Join(Application.Transpose(Range("A1", Cells(Rows.Count, "A").End(xlUp))), "/"), " / ", "/"), "/")
  With CreateObject("Scripting.Dictionary")
    For X = 0 To UBound(Data)
      .Item(Data(X)) = .Item(Data(X)) + 1
    Next
    Range("B1").Resize(.Count) = Application.Transpose(.Keys)
    Range("C1").Resize(.Count) = Application.Transpose(.Items)
  End With
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Here is a macro that should do what you want (source assumed to start at cell A1, output goes to Columns B and C)...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Sub NameCount()
  Dim X As Long, Data As Variant
  Data = Split(Replace(Join(Application.Transpose(Range("A1", Cells(Rows.Count, "A").End(xlUp))), "/"), " / ", "/"), "/")
  With CreateObject("Scripting.Dictionary")
    For X = 0 To UBound(Data)
      .Item(Data(X)) = .Item(Data(X)) + 1
    Next
    Range("B1").Resize(.Count) = Application.Transpose(.Keys)
    Range("C1").Resize(.Count) = Application.Transpose(.Items)
  End With
End Sub[/TD]
[/TR]
</tbody>[/TABLE]

Thanks so much for your help, Rick. How would I modify this script so that it only counts items that have the word "Open" written in cell B1?

Example dataset
Tiger Woods / Greg NormanOpen
Greg NormanOpen
Tiger Woods / Ernie ElsClosed
Ernie Els / Greg Norman / Tiger WoodsOpen
Example desired output
Greg Norman3
Tiger Woods2
Ernie Els1

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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