Copy + Paste a bunch of times!

amwilber

Board Regular
Joined
May 15, 2008
Messages
162
Hello,
How would I copy and paste a selection a bunch of times on a given interval.

Example:

I have an excel file that has a value in it, like building 1. There are then 4 spaces after that text in the excel file. I need to copy the value "building 1" and paste it into cells A2-A5. Then, copy value A6 (Building 2) and paste it into A7-A10....then repeat for thousands of rows. How do I do this?


Building 1



Building 2



Building 3
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Code:
Sub Filldown()

    Dim cnt As Long
    
    For cnt = 1 To Range("A" & Rows.Count).End(xlUp).Row + 4 Step 5
        Range("A" & cnt).Resize(5) = Range("A" & cnt).Value
    Next cnt

End Sub
 
Upvote 0
That doesn't seem to do anything...do I need to alter that code to fit somehow?

Thank you for the help!
 
Upvote 0
Fluff's code assumes it's always 4 blanks between entries; is that right? If not, this would probably work (untested):

Code:
Public Sub CopyPasteBunchOfTimes()

Dim lastRow As Long
Dim thisRow As Long

lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For thisRow = 2 To lastRow
    If Trim$(Cells(thisRow, 1).Value) = "" Then Cells(thisRow, 1).Value = Cells(thisRow - 1, 1).Value
Next thisRow

End Sub

WBD
 
Upvote 0
That code looked like it worked, how do I apply this then across multiple columns? I ran it, but i am not seeing where I would alter this to run across column B for example?

Thanks so much!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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