Hi
I have looked around quite a bit and am looking for a way to fill down a pre-selected range of cells down until the last row that is defined by column A
The most common type of autofill solution is as stated below, but that is not what I am looking for. It needs to autofill based on the cells that are currently selected (it can be one cell, three cells etc...).
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
Selection.AutoFill Destination:=Range("A1:C" & LastRow&), Type:=xlFillDefault
However, the problem is that it is defined by autofilling from A1:C25 (as an example), but the cells that need be autofilled may not always be in columns A:C
I am using the following code. It does the job but it is not efficient. I would like to take out the last two lines and just use the "Selection.AutoFill Destination:=Range(Selection, Selection.End(xlDown)), Type:=xlFillDefault" to take down to correct line (and not the end of the sheet as is currently doing
Assume that cells are pre-selected or highlighted before running the macro.
In my attachment, I have selected the last cells in columns E:C for ease
Sub Autofill_Selection()
'
'AUTOFILL
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
Selection.AutoFill Destination:=Range(Selection, Selection.End(xlDown)), Type:=xlFillDefault
Range(Range("A65536"), Range("A65536").End(xlUp).Offset(1, 0)).Select
Selection.EntireRow.Delete
'
End Sub
View my attachment as an example
Thanks in advance for the help
Bookmarks