What's wrong with my code? run time error 1004
Sub SumAboveF()
Dim r As Range, rAbove As Range
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
Set r = ActiveCell
Set rAbove = Range(r.Offset(-1).End(xlToLeft).Row)
r.Formula = "=SUM(" & rAbove.Address & ")"
End Sub
CodePudding user response:
Here's one way:
Dim rng As Range
With ActiveCell
Set rng = .EntireRow.Cells(1).Resize(1, .Column - 1)
.Formula = "=SUM(" & rng.Address & ")"
End With
