Public Sub FillDownCells()
Dim arrFormulas As Variant
Dim intReply As Integer
Dim lngCurrRow As Long
intReply = MsgBox("This will paste values. Are you sure you want to continue?", _
vbYesNo + vbQuestion)
If intReply = vbYes Then
arrFormulas = Selection.FormulaR1C1
For lngCurrRow = LBound(arrFormulas) To UBound(arrFormulas)
If arrFormulas(lngCurrRow, 1) = "" Then
arrFormulas(lngCurrRow, 1) = "=R[-1]C"
End If
Next lngCurrRow
Selection = arrFormulas
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If
End Sub
It reads the entire selection into an array, scrolls through the array finding the blanks and replacing them with your formula. Then it posts the array back to the spreadsheet, and copies/pastes special the values. The problem with the original procedure was when it selected the blank cells, it didn't recognize cells past the UsedRange. This version doesn't care what the UsedRange is...