Formula for creating summary of vast data

Makjain

New member
Joined
Mar 1, 2014
Messages
3
Reaction score
0
Points
0
Hi

I am not able to generate summary of below data:

GroupFruits
AApple
BApple,Orange
BOrange
BLemon
BApple,Lemon
CLemon,Orange
CLemon,Orange,Apple
CApple,Orange
ALemon,Orange
BApple,Lemon
CLemon,Orange,Apple
BApple,Lemon
CLemon,Orange
DLemon

As per below format:

SummaryAppleOrangeLemon
A
B
C

Basically i want to know count of fruits held by groups.
 
My data is not the way you presented. It is comma separated hence i found below solution

GroupFruitsA - AppleA - OrangeA - LemonB - AppleB - OrangeB - LemonC - AppleC - OrangeC - Lemon
AApple,Orange110000000
BApple,Lemon000101000
BOrange,Apple000110000
BLemon000001000
BApple,Lemon000101000
CLemon,Orange000000011
CLemon,Orange,Apple000000111
CApple,Orange000000110
ALemon,Orange011000000
BApple,Lemon000101000
CLemon,Orange,Apple000000111
BApple,Lemon000101000
CLemon,Orange000000011

=IF(A2="A",IF(ISNUMBER(SEARCH("*Apple*",B2)),"1",0),"0")

In each cell i have entered above formula and for summary below formula

Summary
AppleOrangeLemon
A
121
B
515
C
354
Total
9810

=COUNTIF(D2:D14,"1")
 
Is there any other simple way. This task seemed simple but trick was comma in data.
 
I was hoping you would see the "Text to Columns" transformation
applied to your data.
Doesn't require formulas for that either.
 
Is there any other simple way. This task seemed simple but trick was comma in data.
I realise you wanted a formula, so this is just a bit of mucking about: Select the two column range, including headers (this last is a must) and run the macro below.
First it copies the selected range to a new sheet to the right of the active sheet, then it does a text-to-columns then re-arranges that data to form a 2-column range on which it bases a pivot table which it adds to the new sheet and makes it the same as your summary table.
Developed in Excel 2003, but if it falls over in later versions of Excel (I don't think it will) I can tweak it to work in those later versions.

But how vast is vast?
Code:
Sub blah()
Set myRng = Selection
Set newsht = Sheets.Add(after:=myRng.Parent)
With newsht
  myRng.Copy .Cells(1)
  Set NewRng = .UsedRange
  Set DataSecondColumn = NewRng.Offset(1, 1).Resize(NewRng.Rows.Count - 1, 1)
  DataSecondColumn.TextToColumns Destination:=.Range("B2"), DataType:=xlDelimited, ConsecutiveDelimiter:=True, Comma:=True
  lc = .UsedRange.Columns.Count
  On Error Resume Next
  Set Destn = .Cells(NewRng.Rows.Count + 1, 1)
  For i = 1 To lc - 2
    Set rngtomove = Intersect(DataSecondColumn.Offset(, i), DataSecondColumn.Offset(, i).SpecialCells(2))
    Set RngToMove2 = Union(rngtomove, rngtomove.Offset(, -rngtomove.Column + 1))
    RngToMove2.Copy Destn
    Set Destn = .Cells(Rows.Count, 2).End(xlUp).Offset(1, -1)
    rngtomove.Clear
  Next i
  On Error GoTo 0
  Set PTSource = .UsedRange.Resize(, 2)
End With
PTSource.Value = Application.Trim(PTSource.Value)  'trim spaces
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=PTSource).CreatePivotTable(TableDestination:=newsht.Cells(4, 4), DefaultVersion:=xlPivotTableVersion10)
  .AddFields RowFields:=newsht.Cells(1).Value, ColumnFields:=newsht.Cells(1, 2).Value
  .PivotFields(newsht.Cells(1).Value).Orientation = xlDataField
  .RowGrand = False
End With
End Sub
 
Last edited:
Back
Top