# Copying a formula down a column to the last row with data

#### maclachlan

##### New Member
I apologize if this questions has been asked before on the forum. I did a search but couldn't find anything. I have a spreadsheet with 3 columns.

Column A contains a data pull with the number of rows changing each time the data is refreshed.
Columns B and C contain a formula that needs to be copied from row 5 down the spreadsheet. I would like the formula to be copied 1 row up from the last data of column A

Example

_A_________B_____________C
5_567_____+A5*\$A\$1____+A5*\$C\$1
6_1064____+A6*\$A\$1____+A6*\$C\$1
7_579_____+A7*\$A\$1____+A7*\$C\$1
...
50_1068___+A50*\$A\$1___+A50*\$C\$50
51_End**_____no formulas on this line

Code:
``````Private Sub CommandButton1_Click()

Worksheets("Sheet4").Activate
ActiveWorkbook.Sheets(4).Range("b5:c5").Copy
ActiveSheet.Paste Destination:=Worksheets("Sheet4").Range("b6", Range("a6",End(x1Down))

End Sub``````

### Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try this.
Code:
``````Private Sub CommandButton1_Click()
Dim LastRow as Long
With Worksheets("Sheet4")
LastRow = .Range("A" & Rows.Count).End(xlUp).Row-1
.Range("b5:c5").Copy .Range("b6:B" & LastRow)
End With
End Sub``````

Thanks Norie that works great

Replies
5
Views
105
Replies
5
Views
199
Replies
11
Views
599
Replies
2
Views
247
Replies
4
Views
74

1,217,382
Messages
6,136,240
Members
450,000
Latest member
jgp19

### 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.

### Which adblocker are you using?

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

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