Transpose Macro (Vertical to Horizontal) for a varying Number of rows to varying number of columns.

biostatistician

New Member
Joined
Oct 24, 2014
Messages
11
Hi all,
New this forum. I'm not a VB expert but did some work with VB years ago back in graduate school so I'm not too familiar anymore.

I'm basically trying to take Column G, and transpose it accordingly. For example, STUDY #2 has 3 extra rows in Column G which I want to transpose to ROW K and onward.
I want to do the same for Study 3 and 4 and so on for almost 3000 STUDY #'s. But the number of rows vary. Is there a code to do this? I know it will be conditional and I need the code to realize it's finished transposing for that STUDY # once the next STUDY appears. I've posted an example of what I'm looking for below. Any help with this would be greatly appreciated!

WHAT I HAVE:

A B C D E F G H I J K L
STUDYPresentGenNumberraceshortdiagAdDiRe
1 YF30O8120081201MM**
2 YM20J8341083412OO**
30501
E8888
E8498
3 YM40B8023080235SSY
E9688
E8495
4 YM50B8151081514SS**
8832
E9174
E8498
71894
9556
5NF25M8238282302SOY
8082
8056
2851
81201
920
85011
E8147
E8495
4019
2724
WHAT I NEED:
A BCDEFGHIJKLMNOPQRST
STUDYPresentGenNumberraceshortdiagAdDiRe
1 YF30O8120081201MM**
2 YM20J8341083412OO**30501E8888E8498
3 YM40B8023080235SSYE9688E8495
4 YM50B8151081514SS**8832E9174 E8498 718949556
5NF25M8238282302SOY8082805628518120192085011E8147E8495 40192724

<colgroup><col width="64" span="20" style="width:48pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,214,516
Messages
6,119,980
Members
448,934
Latest member
audette89

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