I am new to VBA, but I have been able to edit my recording enough to get what I want to this point. Here is what I have so far:
The above red relative cell entry results in the correct cell for the edited formula, but for the AutoFill to work properly in the remaining code I need the resulting cell reference to be absolute:
Line: ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""-"",(RC[-6]/R[8]C[3]*RC[-1])"
Result: "K580" = IF(H580=0,"-",(E580/N576)*J580)
Wanted Result: "K580" = IF(H580=0,"-",(E580/$N$576)*J580)
Thanks
Code:
ActiveCell.Offset(-12, 0).Select Range(ActiveCell, ActiveCell.Offset(0, 16)).Select
Selection.Copy
ActiveCell.Offset(12, 0).Select
ActiveSheet.Paste
ActiveCell.Select
Application.CutCopyMode = False
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""-"",(RC[-6]/[COLOR=#ff0000]R[8]C[3][/COLOR]*RC[-1])"
ActiveCell.Select
Selection.AutoFill Destination:=Range(ActiveCell, ActiveCell.Offset(7, 0)), Type:=xlFillDefault
Range(ActiveCell, ActiveCell.Offset(7, 0)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThick
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
The above red relative cell entry results in the correct cell for the edited formula, but for the AutoFill to work properly in the remaining code I need the resulting cell reference to be absolute:
Line: ActiveCell.FormulaR1C1 = "=IF(RC[-3]=0,""-"",(RC[-6]/R[8]C[3]*RC[-1])"
Result: "K580" = IF(H580=0,"-",(E580/N576)*J580)
Wanted Result: "K580" = IF(H580=0,"-",(E580/$N$576)*J580)
Thanks