Hi ExcelForum,

I am new with VBA macro and I need help with my problem.

I am trying to add formula to my vba macro I have this code below:
Public Function AddForumla()


Dim lastRow As Integer
Dim sht As Object

Set sht = ThisWorkbook.Sheets("Payment Breakdown")
lastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row

Range("D" & lastRow + 1).Formula = "=+SUM(D2:"D" & lastRow)"

End Function

I am having trouble in "=+SUM(D2:"D" & lastRow)" part.

hope someone can guide me accordingly.

thanks!