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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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