See below
Sub Sans()
'dim statements to define variable type. save on memory usage
Dim Lrow As Long, Lcol As Long
'Last row statement. Rows.Count is the last row in the sheet.
'End(xlUp)looks from the Rows.Count backwards until it finds the last row with data.
'.Row turns the cell to a row number i.e row 43
' The minus 2 takes 2 from the row number i.e. row 41. THIS IS THE NUMBER YOU NEED TO CHANGE.
'In your last example change it to 6
Lrow = Cells(Rows.Count, 12).End(xlUp).Row - 2
'Similar to the row explanation. The 1 is the row number.
Lcol = Cells(1, Columns.Count).End(xlToLeft).Column
' ranges just the same as a normal range. The 4 is the starting row number, Column "L" is Column 12.
Range("L4").AutoFill Destination:=Range(Cells(4, 12), Cells(4, Lcol)), Type:=xlFillDefault
'As above
Range(Cells(4, 12), Cells(4, Lcol)).AutoFill Destination:=Range(Cells(4, 12), Cells(Lrow, Lcol)), Type:=xlFillDefault
End Sub
Or I suppose another option is to change
Lrow = Cells(Rows.Count, 12).End(xlUp).Row - 2
to
Lrow = Columns(12).Find(what:="*", after:=Cells(4, 12), LookIn:=xlValues).Row - 1
But please note you will have to clear the contents each time before running.
Bookmarks