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
ABCJonathonCat JonathonCatDogBirdFishElephantPandaBear
XYZJonathonDog PeterDogBirdFish
DUAJonathonBird JessicaElephantPandaDogBird
WQHJonathonFish
FDIJonathonElephant
PDUJonathonPanda
IDJJonathonBear
JURPeterDog
FORPeterBird
DEGPeterFish
IMBJessicaElephant
PEDJessicaPanda
IRFJessicaDog
INDJessicaBird

<colgroup><col><col><col span="10"></colgroup><tbody>
</tbody>
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

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,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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