How to paste formulas down to the end of a range using VBA

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Guys!

I'll provide a simple example of what I'd like to do:

I have some formulae in cells E1 and F1 and I'd like to copy and paste them to cell E2 to F2 AFTER data has been pasted in the preceding columns (A:D) until the end of the range of the data in columns A to D.

The data in columns A to D could go from row 2 to row 100, or from row 2 to row 1000.

Does anyone know how to do this, please?

I've pasted very simple formulae below, to save you time:

This formula should go in cell E1: =A1+B1

This formula should go in cell F1: ==C1+D1

Thanks in advance!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try
Code:
Sub Mr2017()
   Range("E2", Range("A" & Rows.Count).End(xlUp).Offset(, 5)).Filldown
End Sub
 
Upvote 0
Try this

Code:
Sub fill()
    Range("E1:F1").AutoFill Destination:=Range("E1:F" & Range("A" & Rows.Count).End(xlUp).Row)
End Sub
 
Upvote 0
Hi Fluff

Thanks for the prompt response.

I tried that code, but nothing happened with my sheet?

I used the data below (which you can copy and paste into cell A1 - it then populates data from cell A1:D5). And I kept the formulae the same in cells E1 and F1 ie =A1+B1 in cell E1 and =C1+D1 in cell F1. However, the code in the post subsequently below, worked - so I've used that, in the meantime.

4632105
1122
1122
1122
1122

<colgroup><col style="width:48pt" width="64" span="6"> </colgroup><tbody>
</tbody>
 
Upvote 0
Try changing the E2 in my code to E1
 
Upvote 0
Ok, yes, it works as intended, now, Fluff.

Thanks for clarifying that.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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