Macro to split my data up into 5 rows per order

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I need a macro to do the following,

I have data in activesheet range A2:AZ last row

Each row has an order number in column A

I Have Another sheet Call "OUTPUT"

Now I dont need every Column copied over Just these ones

A,C,F,V:AE

so
A to A
C to B
F to C
V to D and so on


But this is what i do need,
Each row has data in columns Q:U (5 columns)
I want to make 5 identical rows Just with Column N holding one of the 5 data from Q:U (5 columns)

so i get 5 rows all the same but showing whats in columns Q to U as individual rows

hope thats nice and clear,
please help if you can

Thanks

Tony
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
How about
VBA Code:
Sub tonywatsonhelp()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, cc As Long, nr As Long
   
   With Sheets("Sheet1")
      Ary = .Range("A2:AE" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   ReDim Nary(1 To UBound(Ary) * 5, 1 To 14)
   For r = 1 To UBound(Ary)
      For c = 1 To 5
         nr = nr + 1
         Nary(nr, 1) = Ary(r, 1)
         Nary(nr, 2) = Ary(r, 3)
         Nary(nr, 3) = Ary(r, 6)
         For cc = 1 To 10
            Nary(nr, cc + 3) = Ary(r, cc + 21)
         Next cc
         Nary(nr, 14) = Ary(r, c + 16)
      Next c
   Next r
   Sheets("Sheet2").Range("A2").Resize(nr, 14).Value = Nary
End Sub
 
Upvote 0
Thank you fluff,
this is once again amazing
Thank you so much
Tony
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

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