help to re-arrange data via macro

bobby0066

New Member
Joined
Feb 25, 2005
Messages
3
I've got a machine that is out putting 5 data sets in a row. Each data set contains 8 data points. Data set 1 has data in D, E, F, G, H, I, J, K. Data set 2 is in L, M, N, O, P, Q, R, S and so on. This is in sequential order. The next row contains the next 5 data sets and so on.

I have thousands of rows of data that I keep getting. Trying to put together a macro to help sequentially sort the data. So I'm thinking the following to insert 5 rows.
Dim insertrow
inro = 1
Do While insertrow <= 4
Range("A3").EntireRow.Insert
insertrow = insertrow + 1
Loop
from here how to i create a loop to jump to the next row where i'll need to insert 4 more rows, A7 to accommodate the next group of data.

Now the part i'm not sure about. How to create a loop to move the 4 other datasets in the row down into columns D, E, F, G, H, I, J, K. thoughts? This is what I've thrown together but I don't know how to loop it.
Range("L2:S2").Select
Application.CutCopyMode = False
Selection.Cut
Range("D3").Select
ActiveSheet.Paste

Range("T2:AA2").Select
Application.CutCopyMode = False
Selection.Cut
Range("D4").Select
ActiveSheet.Paste

Range("AB2:AI2").Select
Application.CutCopyMode = False
Selection.Cut
Range("D5").Select
ActiveSheet.Paste

Range("AJ2:AQ2").Select
Application.CutCopyMode = False
Selection.Cut
Range("D6").Select
ActiveSheet.Paste

Any help would be appreciated.
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This Might do???
This code produces an Array of the 5 sets of the Groups of 8 columns for the sheet data and places it in Columns "D to K".
NB:- By changing the last line you can place it were you want !!!
Code:
[COLOR="Navy"]Sub[/COLOR] MG02Aug35
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("D1"), Range("D" & Rows.Count).End(xlUp))
ReDim Ray(1 To Rng.Count * 5, 1 To 8)
c = 1
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]For[/COLOR] Ac = 1 To 40
        col = col + 1
        Ray(c, col) = Dn(, Ac)
        [COLOR="Navy"]If[/COLOR] Ac Mod 8 = 0 [COLOR="Navy"]Then[/COLOR]
            c = c + 1
            col = 0
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] Dn
Range("D1").Resize(c, 8) = Ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,290
Members
449,218
Latest member
Excel Master

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