The equivalent code in RC style allows the formulas to be entered for the entire column in a single statement Rememberthe advantage of RC style formulas is that all the formulas in Columns D Fand most of G are identical

Sub R1C1Style()

' Locate the FinalRow

FinalRow = Range("B65536").End(xlUp).Row ' Enter the first formula

Range("D4:D" & FinalRow).FormulaR1C1 = "=RC[-1]*RC[-2]"

Range("F4:F" & FinalRow).FormulaR1C1 = "=IF(RC[-1],ROUND(RC[-2]*R1C2,2),0)" Range("G4:G" & FinalRow).FormulaR1C1 = "=+RC[-1]+RC[-3]" ' Enter the Total Row Cells(FinalRow + 1, 1).Value = "Total"

Cells(FinalRow + 1, 6).Formula = "=SUM(G4:G" & FinalRow & ")" End Sub

0 0

Post a comment