Add a Grand Total, and format its cell:
strFormula = “=SUM(R[-” & CStr(lngRows - 2) _
& “]C:R[-1]C)”
Debug.Print “Formula: “ & strFormula
strRange = “I” & CStr(lngRows + 2)
Debug.Print “Range: “ & strRange
wks.Range(strRange).FormulaR1C1 = strFormula
wks.Range(strRange).Select
With appExcel.Selection.Font
.Name = “Calibri”
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = 2
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
With appExcel.Selection
.Font.Bold = True
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With
With appExcel.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With appExcel.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With appExcel.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Analyzing Data with Excel 3