Transpose & Create New Rows

SimonLock94

New Member
Joined
Feb 11, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm very much new to the world of VBA but I have a transposing problem I need help on!

I'm working with a large excel file - columns A through to I give details on a company, these are all consistent throughout the 9,000 or so rows. Columns J onwards (up to a maximum of column EF) given the names of officers of those companies. Each company has a varying number of officers so the number of columns used per row is different.

I want to give each officer a row of their own and match it up with the company information. So essentially I want to transpose columns J onwards from horizontal to vertical, and create the same number of new rows to match the number of officers. As yet I can't figure out a way to do this other than manually.

This is a sample of the sheet I have:

Start Data.JPG


And this is how I ultimately want it to look:

Desired Result.JPG


Any advice would be greatly appreciated here!

S
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
in Power Query (change 2 in Merge step to the number of columns you need to skip):

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    Merge = Table.CombineColumns(Source,List.Skip(Table.ColumnNames(Source),2),Combiner.CombineTextByDelimiter(";;", QuoteStyle.None),"Officer"),
    OfficerList = Table.TransformColumns(Merge, {{"Officer", each List.RemoveItems(Text.Split(_,";;"),{""})}}),
    Result = Table.ExpandListColumn(OfficerList, "Officer")
in
    Result

Book1
ABCDEFGHIJK
1CompanyRevenuesOfficer1Officer2Officer3Officer4Company Revenues Officer
2A$ 76,336,583Adam AntA$ 76,336,583Adam Ant
3B$ 51,186,087Bruce BannerB$ 51,186,087Bruce Banner
4C$ 1,834,724Charlie ChaplinC$ 1,834,724Charlie Chaplin
5D$ 77,305,520Delta DawnD$ 77,305,520Delta Dawn
6E$ 70,855,470Emilio EstevezNick NolteE$ 70,855,470Emilio Estevez
7F$ 14,584,070Fannie FarmerOzzy OsbourneE$ 70,855,470Nick Nolte
8G$ 24,165,454Galileo GalileiPol PotF$ 14,584,070Fannie Farmer
9H$ 52,189,470Harry HoudiniQuintavius QuireF$ 14,584,070Ozzy Osbourne
10I$ 68,743,148Igor IvanovRyan ReynoldsG$ 24,165,454Galileo Galilei
11J$ 88,684,021Jonah JamesonSue StormG$ 24,165,454Pol Pot
12K$ 11,299,468Kris KristoffersonTina TurnerWalt WhitmanH$ 52,189,470Harry Houdini
13L$ 31,543,586Lois LaneUncle UgoXavier XmanH$ 52,189,470Quintavius Quire
14M$ 39,722,173Micky MantleVictor VonDoomYvette YoungZig ZiglarI$ 68,743,148Igor Ivanov
15I$ 68,743,148Ryan Reynolds
16J$ 88,684,021Jonah Jameson
17J$ 88,684,021Sue Storm
18K$ 11,299,468Kris Kristofferson
19K$ 11,299,468Tina Turner
20K$ 11,299,468Walt Whitman
21L$ 31,543,586Lois Lane
22L$ 31,543,586Uncle Ugo
23L$ 31,543,586Xavier Xman
24M$ 39,722,173Micky Mantle
25M$ 39,722,173Victor VonDoom
26M$ 39,722,173Yvette Young
27M$ 39,722,173Zig Ziglar
28
Sheet2
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
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