How to input a Sum Formula in vraiable range in Excel

Hi Guys, I have this VB code in Excel which does a filter on a range looks for yesterdays date on row 20 in a tab called "Murex Accrual PnL" then pastes it to cell K12 in a tab called "Email London 2".The range it pastes is 9 columns. The amount of rows is variable depending on the day. In cell R13 is a numeric column which I wish to insert a sum Formula at the bottom (eg. in Column K ) via code. The cell range would be depending on how many lines. Thus it would be from ("R13")to  ("R13").End(xlDown) and the sum formula would go in ("R13"). End(xlDown).  Offset(1).
Sub NewDeals()
Dim vdate As String

'vdate = CDate(Range("trade_Date").Value)

vdate = Range("trade_Date").Value
vdate = Format(vdate, "dd-mmm-yy")
 '   Rows("20:20").Select
  '  Selection.AutoFilter
    ActiveSheet.Range("$A$20:$AZ$250000").AutoFilter Field:=14, Criteria1:=vdate
    'ActiveWindow.SmallScroll ToRight:=33
    ActiveSheet.Range("$A$20:$AZ$250000").AutoFilter Field:=42, Criteria1:= _
        ">=500", Operator:=xlOr, Criteria2:="<=-500"
    Range(Selection, Selection.End(xlDown)).Select
    Sheets("Email London2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
JustinFinancial ControlAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
Would the SUM only be for column K and only sum that column?

If so try this.
With Sheets("Email London2")
    .Range("K12").PasteSpecial Paste:=xlPasteValues
    .Range("K" & Rows.Count).End(xlUp).Offset(1).FormulaR1C1 = "=SUM(R12C11:R[-1]C)"
End With

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roy CoxGroup Finance ManagerCommented:
You could use an Excel Table with Total row
JustinFinancial ControlAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.