Copy Down Data Until end of range

chrono2483

Board Regular
Joined
Aug 23, 2014
Messages
164
Office Version
  1. 2016
Hello,

My goal is to be able to copy down data until the end of the range. The range can vary, based on the size of the raw data pasted. Running the following script works to copy down the data (not the prettiest, but it looks to work), however because it doesn't know when to end, it errors out. Is there a way to tell it to loop until the last row in the range?

Code:
'Copy Down Month
Range("A1").Select
Selection.End(xlDown).Select
 Range(Selection, Selection.End(xlDown)).Select
 Selection.SpecialCells(xlCellTypeBlanks).Select
   Selection.FormulaR1C1 = "=R[-1]C"
   Selection.End(xlDown).Select
   Range("A1").Select
Selection.End(xlDown).Select
 Range(Selection, Selection.End(xlDown)).Select
 Selection.SpecialCells(xlCellTypeBlanks).Select
   Selection.FormulaR1C1 = "=R[-1]C"
   Selection.End(xlDown).Select
   Range("A1").Select
Selection.End(xlDown).Select
 Range(Selection, Selection.End(xlDown)).Select
 Selection.SpecialCells(xlCellTypeBlanks).Select
   Selection.FormulaR1C1 = "=R[-1]C"
   Selection.End(xlDown).Select

Thank you.
 

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
My goal is to be able to copy down data until the end of the range.

When you make statements like the above you really need to explain what your data looks like.
Anyway a guess...

Code:
Sub FillCell2()
Dim lr As Long
lr = Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
    With Range("A2:A" & lr)
        .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
        .Value = .Value
    End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

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