extracting data from table

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
529
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a long series of data that contains names in column A, Products in column B and quantities in column C
eg:
<table>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>John</td>
<td>Apples</td>
<td>7</td>
</tr>
<tr>
<td>Steve</td>
<td>Apples</td>
<td>4</td>
</tr>
<tr>
<td>Pete</td>
<td>Bananas</td>
<td>2</td>
</tr>
<tr>
<td>John</td>
<td>Melon</td>
<td>1</td>
</tr>
<tr>
<td>Pete</td>
<td>Apples</td>
<td>6</td>
</tr>
<tr>
<td>Dave</td>
<td>Bananas</td>
<td>3</td>
</tr>
</table>



I need to be able to move the quantites into a pre built table that has a list of the names down in 1 column and a list of the products across the top row.
eg
<table>
<tr>
<th>Name</th>
<th>Apples</th>
<th>Bananas</th>
<th>Melon</th>
</tr>
<tr>
<td>John</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Steve</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Pete</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Dave</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>


Anyone able to help?

thanks

Neil
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
using PowerQuery (Get&Transform)

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table31"]}[Content],
    #"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[Fruit]), "Fruit", "Qty", List.Sum)
in
    #"Pivoted Column"[/SIZE]

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Name[/td][td=bgcolor:#5B9BD5]Fruit[/td][td=bgcolor:#5B9BD5]Qty[/td][td][/td][td=bgcolor:#70AD47]Name[/td][td=bgcolor:#70AD47]Apples[/td][td=bgcolor:#70AD47]Bananas[/td][td=bgcolor:#70AD47]Melon[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]John[/td][td=bgcolor:#DDEBF7]Apples[/td][td=bgcolor:#DDEBF7]
7​
[/td][td][/td][td=bgcolor:#E2EFDA]Dave[/td][td=bgcolor:#E2EFDA][/td][td=bgcolor:#E2EFDA]
3​
[/td][td=bgcolor:#E2EFDA][/td][/tr]

[tr=bgcolor:#FFFFFF][td]Steve[/td][td]Apples[/td][td]
4​
[/td][td][/td][td]John[/td][td]
7​
[/td][td][/td][td]
1​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Pete[/td][td=bgcolor:#DDEBF7]Bananas[/td][td=bgcolor:#DDEBF7]
2​
[/td][td][/td][td=bgcolor:#E2EFDA]Pete[/td][td=bgcolor:#E2EFDA]
6​
[/td][td=bgcolor:#E2EFDA]
2​
[/td][td=bgcolor:#E2EFDA][/td][/tr]

[tr=bgcolor:#FFFFFF][td]John[/td][td]Melon[/td][td]
1​
[/td][td][/td][td]Steve[/td][td]
4​
[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Pete[/td][td=bgcolor:#DDEBF7]Apples[/td][td=bgcolor:#DDEBF7]
6​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]Dave[/td][td]Bananas[/td][td]
3​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]
 
Upvote 0
Hi Sandy

Thanks for the reply, but you lost me at "PowerQuery".

How do i use that code?

thanks

Neil
 
Upvote 0
Hi, here is a formula option you could try.


Excel 2013/2016
ABCDEFGH
1JohnApples7NameApplesBananasMelon
2SteveApples4John701
3PeteBananas2Steve400
4JohnMelon1Pete620
5PeteApples6Dave030
6DaveBananas3
Sheet1
Cell Formulas
RangeFormula
F2=SUMIFS($C:$C,$A:$A,$E2,$B:$B,F$1)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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