Sub Macro1()
Dim ColumnA As String
Dim ColumnB As String
Dim ColumnC As String
Dim ColumnD As String
ColumnA = Mid(ActiveCell.Offset(0, -1).Address, 2, 1)
ColumnB = Mid(ActiveCell.Offset(0, -2).Address, 2, 1)
ColumnC = Mid(ActiveCell.Address, 2, 1)
ColumnD = "D"
ActiveCell.Formula = "=IFERROR((" & ColumnA & ActiveCell.Row & _
"-" & ColumnB & ActiveCell.Row & _
"+1)/" & ColumnC & "$3*$" & ColumnD & ActiveCell.Row & "%,0)"
Range(ColumnC & "5:" & ColumnC & Cells(Rows.Count, ColumnB).End(xlUp).Row).Select
Selection.FillDown
End Sub