Macro to space 6 rows between data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,570
Office Version
  1. 2021
Platform
  1. Windows
I have a macro to copy data from Column P on sheet2 to Column A on Sheet3

I need code that will insert 6 rows between each item in Col A on Sheet3.


I tried to write code to do this, but cannot get it to work


Code:
 Sub Insert6Rows()
Dim LR As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row

With Range("A1:A" & LR)
.EntireRow.Offset(6).Insert
End With

End Sub


It would be appreciated if someone could kindly provide me with the code
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Can you post the code you are using to copy/paste the data?
 
Upvote 0
It would be easier to just put the data 6 rows down than to insert 6 rows after the fact. What code are you using to pull the data now?

EDIT: I was too slow :) ...looks like we're thinking the same thing.
 
Last edited:
Upvote 0
Hi Mumps

Thanks for the reply


Code:
 Sub Copy_Branch_Names()
  
   
    
  With Sheets(2)
  Dim LR As Long
LR = .Cells(.Rows.Count, "P").End(xlUp).Row
    
     .Range("P1:P" & LR).Copy Destination:=Sheets(3).Range("A1")

    End With
    
    End Sub
 
Last edited:
Upvote 0
How about
Code:
Sub copyData()
   Dim ary As Variant
   Dim i As Long, j As Long
   
   j = 1
   ary = Sheets(2).Range("P1", Sheets(2).Range("P" & Rows.Count).End(xlUp))
      With Sheets(3)
         For i = 1 To UBound(ary)
            .Range("A" & j).Value = ary(i, 1)
            j = j + 7
         Next i
      End With
End Sub
 
Upvote 0
Thanks for the help Fluff. Your code works perfectly
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,041
Messages
6,128,461
Members
449,455
Latest member
jesski

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