Copy/Autofill formula to last cell

tipd

New Member
Joined
Apr 17, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I cannot get this to work, only cell B2 has the formula and it will not copy down the row to the last row with data. What have I done wrong?

ActiveCell.FormulaR1C1 = "=R[-1]C+1"

Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row).AutoFill Destination:=Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Welcome to the Board!

You probably need to look at column A to determine how far down to go, since column B does not have all the rows populated yet.
You can combine both lines into this (you don't need to use Autofill, just populate all the rows at once with a formula):
VBA Code:
Range("B2:B" & Cells(Rows.Count, "A").End(xlUp).Row).FormulaR1C1 = "=R[-1]C+1"
 
Upvote 0
Solution
Welcome to the Board!

You probably need to look at column A to determine how far down to go, since column B does not have all the rows populated yet.
You can combine both lines into this (you don't need to use Autofill, just populate all the rows at once with a formula):
VBA Code:
Range("B2:B" & Cells(Rows.Count, "A").End(xlUp).Row).FormulaR1C1 = "=R[-1]C+1"
Thank you Joe4, that was it! I feel so silly.
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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