Transpose certain cells based on a condition

NicoleN

New Member
Joined
Apr 9, 2018
Messages
5
Hi There,

Hoping someone may have a suggestion for me (VBA, or formula, or other). I want to transpose certain cells based on a condition in a separate column (but same row). To illustrate with an example, I would like all values from column C to be transposed into the relevant row depending on Column B's value. E.g. Column B to contain one line of "Jonathon" and all items in Column C against Jonathon's name are transposed in Row 1. Then Same for other names in Column B. See example of initial data below (A-C columns), and then desired format (E-L columns).
I've seen the INDEX formula used to transpose a certain number of values, but in my case the number of values to be transposed will range from 3 to about 8, so I can set a certain amount in the formula.
Would appreciate any ideas. Thank you in advance!

A B C D E F G H I J K L
[TABLE="width: 788"]
<colgroup><col><col><col span="10"></colgroup><tbody>[TR]
[TD]ABC[/TD]
[TD]Jonathon[/TD]
[TD]Cat[/TD]
[TD] [/TD]
[TD]Jonathon[/TD]
[TD]Cat[/TD]
[TD]Dog[/TD]
[TD]Bird[/TD]
[TD]Fish[/TD]
[TD]Elephant[/TD]
[TD]Panda[/TD]
[TD]Bear[/TD]
[/TR]
[TR]
[TD]XYZ[/TD]
[TD]Jonathon[/TD]
[TD]Dog[/TD]
[TD] [/TD]
[TD]Peter[/TD]
[TD]Dog[/TD]
[TD]Bird[/TD]
[TD]Fish[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]DUA[/TD]
[TD]Jonathon[/TD]
[TD]Bird[/TD]
[TD] [/TD]
[TD]Jessica[/TD]
[TD]Elephant[/TD]
[TD]Panda[/TD]
[TD]Dog[/TD]
[TD]Bird[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]WQH[/TD]
[TD]Jonathon[/TD]
[TD]Fish[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]FDI[/TD]
[TD]Jonathon[/TD]
[TD]Elephant[/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] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]IRF[/TD]
[TD]Jessica[/TD]
[TD]Dog[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]IND[/TD]
[TD]Jessica[/TD]
[TD]Bird[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Book1
ABCDEFGHIJKL
1ABCJonathonCatJonathonCatDogBirdFishElephantPandaBear
2XYZJonathonDogPeterDogBirdFish
3DUAJonathonBirdJessicaElephantPandaDogBird
4WQHJonathonFish
5FDIJonathonElephant
6PDUJonathonPanda
7IDJJonathonBear
8JURPeterDog
9FORPeterBird
10DEGPeterFish
11IMBJessicaElephant
12PEDJessicaPanda
13IRFJessicaDog
14INDJessicaBird
Sheet1


If E1:E3 must also produced by means of a formula...

In E1 control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IFERROR(INDEX($B$1:$B$14,SMALL(IF(FREQUENCY(IF(1-($B$1:$B$14=""),MATCH($B$1:$B$14,$B$1:$B$14,0)),
     ROW($B$1:$B$14)-ROW($B$1)+1),ROW($B$1:$B$14)-ROW($B$1)+1),ROWS($E$17:E17))),"")

In F1 control+shift+enter, not just enter, copy across, and down:
Rich (BB code):
=IFERROR(IF($E17="","",INDEX($C$1:$C$14,SMALL(IF($B$1:$B$14=$E17,ROW($C$1:$C$14)-ROW($C$1)+1),COLUMNS($F1:F1)))),"")
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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