Need Help with a Macro to Transpose Data PLEASE!!!

ycz0352

New Member
Joined
Nov 1, 2012
Messages
1
Guys,

I have the following data table...

Inv_Month</SPAN>Description</SPAN>Company</SPAN>Labor Category</SPAN>Rate</SPAN>Bid Rate</SPAN>CLIN_0001</SPAN>CLIN_0002</SPAN>CLIN_0003</SPAN>CLIN_0004</SPAN>CLIN_0005</SPAN>CLIN_0006</SPAN>CLIN_0007</SPAN>CLIN_0008</SPAN>CLIN_0009</SPAN>CLIN_0010</SPAN>
10/1/12</SPAN>Joe Smith</SPAN>ABC</SPAN>VP</SPAN>$50 </SPAN>$50 </SPAN>1.0</SPAN>2.0</SPAN>3.0</SPAN>4.0</SPAN>5.0</SPAN>6.0</SPAN>7.0</SPAN>8.0</SPAN>9.0</SPAN>10.0</SPAN>
10/1/12</SPAN>Ed Jones</SPAN>CDE</SPAN>VP2</SPAN>$25 </SPAN>$10 </SPAN>10.0</SPAN>9.0</SPAN>8.0</SPAN>7.0</SPAN>6.0</SPAN>5.0</SPAN>4.0</SPAN>3.0</SPAN>2.0</SPAN>1.0</SPAN>

<TBODY>
</TBODY><COLGROUP><COL><COL><COL><COL><COL><COL><COL span=10></COLGROUP>

That I need to transposed to this:

Inv_Month</SPAN>Description</SPAN>Company</SPAN>Labor Category</SPAN>Rate</SPAN>Bid Rate</SPAN>CLIN</SPAN>Hours</SPAN>
10/1/12</SPAN>Ed Jones</SPAN>CDE</SPAN>VP2</SPAN>$25 </SPAN>$10 </SPAN>0001</SPAN>10.0</SPAN>
10/1/12</SPAN>Ed Jones</SPAN>CDE</SPAN>VP2</SPAN>$25 </SPAN>$10 </SPAN>0002</SPAN>9.0</SPAN>
10/1/12</SPAN>Ed Jones</SPAN>CDE</SPAN>VP2</SPAN>$25 </SPAN>$10 </SPAN>0003</SPAN>8.0</SPAN>
10/1/12</SPAN>Ed Jones</SPAN>CDE</SPAN>VP2</SPAN>$25 </SPAN>$10 </SPAN>0004</SPAN>7.0</SPAN>
10/1/12</SPAN>Joe Smith</SPAN>ABC</SPAN>VP</SPAN>$50 </SPAN>$50 </SPAN>0001</SPAN>1.0</SPAN>
10/1/12</SPAN>Joe Smith</SPAN>ABC</SPAN>VP</SPAN>$50 </SPAN>$50 </SPAN>0002</SPAN>2.0</SPAN>
10/1/12</SPAN>Joe Smith</SPAN>ABC</SPAN>VP</SPAN>$50 </SPAN>$50 </SPAN>0003</SPAN>3.0</SPAN>
10/1/12</SPAN>Joe Smith</SPAN>ABC</SPAN>VP</SPAN>$50 </SPAN>$50 </SPAN>0004</SPAN>4.0</SPAN>

<TBODY>
</TBODY><COLGROUP><COL><COL><COL><COL><COL><COL><COL span=2></COLGROUP>


Any assistance is greatly appreciated!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi and welcome to the forum,

Does it have to be a macro or would a formula solution suffice?
A possible formula approach might be as follows.

Your initial setup:

Sheet1
ABCDEFGHIJ
1Inv_MonthDescriptionCompanyLabor CategoryRateBid RateCLIN_0001CLIN_0002CLIN_0003CLIN_0004
210/01/2012Joe SmithABCVP$50$501234
310/01/2012Ed JonesCDEVP2$25$1010987

<tbody>
</tbody>
Excel 2010

The output:

Sheet2
ABCDEFGH
1Inv_MonthDescriptionCompanyLabor CategoryRateBid RateCLINHours
210/01/2012Joe SmithABCVP$50$5000011
310/01/2012Joe SmithABCVP$50$5000022
410/01/2012Joe SmithABCVP$50$5000033
510/01/2012Joe SmithABCVP$50$5000044
610/01/2012Ed JonesCDEVP2$25$10000110
710/01/2012Ed JonesCDEVP2$25$1000029
810/01/2012Ed JonesCDEVP2$25$1000038
910/01/2012Ed JonesCDEVP2$25$1000047

<tbody>
</tbody>
Excel 2010

Worksheet Formulas
CellFormula
A2=INDEX(Sheet1!A$2:A$3,
ROUNDUP(ROWS(A$1:A1)/4,0)
)
G2=SUBSTITUTE(INDEX(Sheet1!$G$1:$J$1,
MOD(ROWS(A$1:A4),4)+1
),"CLIN_",""
)
H2=INDEX(Sheet1!$G$2:$P$3,
ROUNDUP(ROWS(F$1:F1)/4,0),
MOD(ROWS(A$1:A4),4)+1
)

<tbody>
</tbody>

<tbody>
</tbody>
Note:

  • Change the formulae ranges accordingly as appropriate for your entire dataset.
  • Drag the formulae in A2 across to F2 and down as far as required. Drag the formulae in G2 and H2 down as far as required.
  • The 4 in the formulae refer to 4 CLIN numbers, you can change this to 10 and adjust the Sheet1 column references (the first argument of the INDEX function) if you want all ten.
  • You can copy and paste the results as values over your original data if that is what you want.
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,398
Members
449,155
Latest member
ravioli44

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