VBA to fill formula until last row

adammon

New Member
Joined
Apr 8, 2015
Messages
14
Hi,

I'm using the following code in VBA and want to have the formula populate down column S to the end of the data set. I'd like to use column A to determine my last cell with data in it. The formula will always begin in cell S7, however the S15 that I have in the code isn't always necessarily going to be the end of the data set. Any help would be greatly appreciated.

Code:
Sub enter_formulas()
Range("S7:S15").Formula = "=CONCATENATE(AB7&""-""&T7&""-""&V7&""-""&AD7&""-""&AE7)"
End Sub

Thanks.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try this
Code:
Range("S7").Formula = "=CONCATENATE(AB7&""-""&T7&""-""&V7&""-""&AD7&""-""&AE7)"
Range(Cells(7, 19), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 19)).FillDown
 
Upvote 0
Or...

Code:
Sub enter_formulas()
    Dim LR As Long: LR = Range("A" & Rows.Count).End(xlUp).Row
    Range("S7:S" & LR).Formula = "=CONCATENATE(AB7&""-""&T7&""-""&V7&""-""&AD7&""-""&AE7)"
End Sub
 
Upvote 0
I know it's been a while, but thank you both for the help on this.

I'm not sure if I should make new post for this, but since I used Jeff's code I figured it would be easier to ask on this one. What if i want to run the formula to the end of the data set + and extra 50 rows to allow for data to be added if needed after running the macro once.
 
Upvote 0
Try
Code:
Sub enter_formulas()
    Dim LR As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row + 50
    Range("S7:S" & LR).Formula = "=CONCATENATE(AB7&""-""&T7&""-""&V7&""-""&AD7&""-""&AE7)"
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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