stacking in Excel using VBA

carambo

New Member
Joined
Apr 1, 2009
Messages
1
I would like to try to use my Function I have been using in Excel in a VBA code to do stacking in EXCEL. I have some data that is coming out of a program in a formate that is not usable and needs to be reformated.

The function I use is

=OFFSET($B$1,MOD(ROWS($A$1:A1)-1,11),INT((ROWS($A$1:A1)-1)/11))

The data I get is

[TABLE="width: 377"]
<tbody>[TR]
[TD]Sample Pct LC
[/TD]
[TD="align: right"]100.2
[/TD]
[TD="align: right"]99.9
[/TD]
[TD="align: right"]97.8
[/TD]
[TD="align: right"]99.8
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (2)
[/TD]
[TD="align: right"]100.9
[/TD]
[TD="align: right"]97.5
[/TD]
[TD="align: right"]97.4
[/TD]
[TD="align: right"]98.3
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (3)
[/TD]
[TD="align: right"]99.2
[/TD]
[TD="align: right"]98.8
[/TD]
[TD="align: right"]96.2
[/TD]
[TD="align: right"]101.3
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (4)
[/TD]
[TD="align: right"]99.4
[/TD]
[TD="align: right"]99.2
[/TD]
[TD="align: right"]97.8
[/TD]
[TD="align: right"]100.0
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (5)
[/TD]
[TD="align: right"]96.6
[/TD]
[TD="align: right"]100.0
[/TD]
[TD="align: right"]98.1
[/TD]
[TD="align: right"]101.7
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (6)
[/TD]
[TD="align: right"]99.9
[/TD]
[TD="align: right"]99.3
[/TD]
[TD="align: right"]99.5
[/TD]
[TD="align: right"]98.2
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (7)
[/TD]
[TD="align: right"]100.6
[/TD]
[TD="align: right"]99.0
[/TD]
[TD="align: right"]98.7
[/TD]
[TD="align: right"]97.8
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (8)
[/TD]
[TD="align: right"]99.6
[/TD]
[TD="align: right"]100.3
[/TD]
[TD="align: right"]97.9
[/TD]
[TD="align: right"]100.3
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (9)
[/TD]
[TD="align: right"]99.0
[/TD]
[TD="align: right"]100.7
[/TD]
[TD="align: right"]97.5
[/TD]
[TD="align: right"]98.8
[/TD]
[/TR]
[TR]
[TD]Sample Pct LC (10)
[/TD]
[TD="align: right"]100.6
[/TD]
[TD="align: right"]98.4
[/TD]
[TD="align: right"]98.1
[/TD]
[TD="align: right"]97.8
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]NA
[/TD]
[TD]NA
[/TD]
[TD]NA
[/TD]
[TD]NA
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]4B20
[/TD]
[TD]4B23
[/TD]
[TD]4B28
[/TD]
[TD]4B29
[/TD]
[/TR]
</tbody>[/TABLE]



I then need to take some of the data and copy and transpose it then insert 11 blank lines.

[TABLE="width: 121"]
<tbody>[TR]
[TD]4B20
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]4B23
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]4B28
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]4B29
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I then copy the function above into column B next to the first number and pull it down to the last blank line to stack all the rest of the numbers into a formate that I can use. (See below) (I insert NA to allow me to later remove it so I have a blank line between each stack of numbers) I would like to do all this with VBA code but don't even know where to start or how to translate the function into VBA code so any help would be greatly appreciated...

[TABLE="width: 185"]
<tbody>[TR]
[TD]4B20
[/TD]
[TD="align: right"]100.1977
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]100.8927
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.24877
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.42519
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]96.58111
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.90633
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]100.5639
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.59358
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.00018
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]100.5906
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]NA
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.89981
[/TD]
[/TR]
[TR]
[TD]4B23
[/TD]
[TD="align: right"]97.4644
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.82834
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.15802
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]100.0035
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.26171
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.95064
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]100.3093
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]100.7426
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.38167
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]NA
[/TD]
[/TR]
[TR]
[TD]4B28
[/TD]
[TD="align: right"]97.77127
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]97.42067
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]96.2485
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]97.81313
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.0617
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]99.48243
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.7472
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]97.92826
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]97.46515
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.0617
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]NA
[/TD]
[/TR]
[TR]
[TD]4B29
[/TD]
[TD="align: right"]99.75789
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.27332
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]101.322
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]101.322
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]101.322
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]101.322
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.0617
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.0617
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]98.0617
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]NA
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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