Dim WS As Worksheet Dim f As Worksheet Dim lastRow As Long Set WS = Sheets("Sheet1") Set f = Sheets("Sheet2") lastRow = f.Cells(f.Rows.Count, "K").End(xlUp).Row f.Range("K7:K" & lastRow).Formula = "='" & WS.Name & "'!$C$17"