Macro to split my data up into 5 rows per order

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,978
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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,180
Office Version
  1. 365
Platform
  1. Windows
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
 

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,978
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Thank you fluff,
this is once again amazing
Thank you so much
Tony
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,180
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,257
Messages
5,769,075
Members
425,515
Latest member
baltusf

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
Top