I have asked and have obtained the codes to copy and paste down a column based on a reference cell. The macro is able to skip blank cell and move to the next filled cell until the last cell. Xld has kindly provided the workable codes and they work fine.
I now wish to alter this codes so that instead of it will only works within a range I selected. That mean instead of the codes executing all the way down to the last reference cell it will only perform within the selected range. Below is the codes provided by Xld I like to know how to change it to suit the new requirement as described above. Thanks in advance
[vba]Public Sub copy_formula()
Dim LastRow As Long
Dim StartCell As Range
Dim rng As Range
Set StartCell = Application.InputBox("Select first cell of match range with the mouse", Type:=8)
If Not StartCell Is Nothing Then
With ActiveCell
LastRow = Cells(Rows.Count, StartCell.Column).End(xlUp).Row
.Offset(1, 0).Resize(LastRow - 1).ClearContents
Set rng = Cells(.Row + 1, StartCell.Column).Resize(LastRow).SpecialCells(xlCellTypeBlanks).Offset(0, .Column - StartCell.Column)
.Copy .Resize(LastRow)
rng.ClearContents
End With
End If
End Sub[/vba]