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>
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Watch MrExcel Video

Forum statistics

Threads
1,108,917
Messages
5,525,621
Members
409,657
Latest member
19JimRon72

This Week's Hot Topics

Top