Stack first 100 rows of 4 column group on top of each other VBA

eddster

New Member
Joined
Oct 11, 2017
Messages
25
Hi All

So, I have a large data set which has four standard column inputs lets say A, B, C, D (but many (100's) of them working across the page from left to right so A,B,C,D,A,B,C,D,A,B,C,D ETC) I want to stack the data so that all the A's are stacked together in an new A column on on a separate worksheet then all the B's adjacent to A on the the worksheet etc etc. I also only want to pull the data from the first 100 rows of each column,

hopefully the table below shows what i mean:

in terms of data size I currently have circa 726 columns of A's, 726 columns of B's, 726 columns of C's 726 columns of D's currently in that patern of A,B,C,D,A,B,C,D,A,B,C,D.......

Any help gratefully received, ideally a macro I think as my non macro routes for this causing things to hang a bit

A1B1C1D1A2B2C2D2A3B3
ROWS 1- 100ROWS 1-100ROWS 1-100ROWS 1-100ROWS 1-100ROWS 1-100ROWS 1-100ROWS 1-100ROWS 1-100ROWS 1-100
so in new worksheet
ABCD
A1 ROWS 1 - 100 B1 ROWS 1 - 100C1 ROWS 1 - 100D1 ROWS 1 - 100
A2 ROWS 1 -100B2 ROWS 1 - 100C2 ROWS 1 - 100D2 ROWS 1 - 100
A3 ROWS 1- 100B3 - ROWS 1 -100C3 ROWS 1- 100 D3 ROWS 1 - 100
ETCETCETCETC
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Assuming original data is on 'Sheet1' and 'Sheet2' exists with nothing on it, try this with a copy of your workbook.

VBA Code:
Sub Stack_Cols()
  Dim c As Long
  
  With Sheets("Sheet1")
    For c = 1 To .Cells(1, Columns.Count).End(xlToLeft).Column Step 4
      .Cells(1, c).Resize(100, 4).Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Next c
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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