VBA to fill formula down till last row in column

calendar_today Asked Sep 11, 2014
thumb_up 13 upvotes
history Updated April 16, 2026

Question posted 2014 · +3 upvotes

So I’m working on a project and I’m trying to get my VBA code to draw down the formula that’s in cell M3 all the way down to the end of the data set. I’m using column L as my base to determine what the last cell with data in it is. My formula is a concatenate of two cells with a text comma in-between them. So in excel my formula is =G3&”,”&L3

I want excel to draw down this formula so in cell M4 it would be =G4&”,”&L4 Cell M5 would be =G5&”,”&L5 and so on.

My code looks like:

Range("$M$3").Formula = Range("G3") & (",") & Range("L3")

Dim Lastrow As Long

Application.ScreenUpdating = False

Lastrow = Range("L" & Rows.Count).End(xlUp).Row
Range("M4").FormulaR1C1 = Range("G4") & (",") & Range("L4")
Range("M4").AutoFill Destination:=Range("M4:M" & Lastrow)
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True

My output is simply pulling down the text values from cell M3 all the way down to the end of the data set. I’ve searched around for several hours trying to look for a fix, but can’t seem to find one that is trying to accomplish what I’m going for.

Accepted answer +13 upvotes

It’s a one liner actually. No need to use .Autofill

Range("M3:M" & LastRow).Formula = "=G3&"",""&L3"

Excel VBA objects referenced (5)

  • Application — Using events with the Application object
  • Application — Working with Other Applications
  • Range — Refer to Cells by Using a Range Object
  • Range — Delete Duplicate Entries in a Range
  • Rows.Count — Count function (Microsoft Access SQL)

Top excel-vba Q&A (6)

+13 upvotes ranks this answer #39 out of 136 excel-vba solutions on this site .