View Single Post
 
Old 02-28-2012, 07:41 PM
JBeaucaire JBeaucaire is offline Windows XP Office 2003
Advanced Beginner
 
Join Date: Dec 2011
Posts: 51
JBeaucaire is on a distinguished road
Default

No need to iterate or loop. You can spot the LastRow (LR) and LastColumn (LC), store them in a variable, the insert the formulas all at once using the R1C1 syntax:

Code:
Option Explicit

Sub AddFormulas()
Dim LR As Long, LC As Long

    LR = Cells(Rows.Count, 1).End(xlUp).Row
    LC = Cells(1, Columns.Count).End(xlToLeft).Column
    
    With Range(Cells(LR + 1, 1), Cells(LR + 1, LC))
        .FormulaR1C1 = "=MAX(R2C:R[-1]C)"
    End With

End Sub
Reply With Quote