Sum Macro

lakshmipathi123

Board Regular
Joined
Jul 10, 2012
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have query regarding SUM macro. I need a sum code which is already done SUM. Like mentioned below. Leave 1st SUM and do same SUM in below column.

With Range("E" & Rows.count).End(xlUp).Offset(2, 0).Resize(, 5)
.FormulaR1C1 = "=SUM(R2C:R[-2]C)"
End With
2
2
3
3
=SUM(E6:E9) First SUM
=SUM(F6:F9) First SUM
=SUM(E6:E9) Second SUM required
=SUM(E6:E9) Second SUM required

<tbody>
</tbody>
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hello All,

I got the answers...see below code

'Do SUM
Application.StatusBar = "SUM Check..."
With Range("E" & Rows.count).End(xlUp).Offset(-2, 0).Resize(, 5)
.FormulaR1C1 = "=SUM(R2C:R[-1]C)"
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlDouble
.Font.Bold = True
End With

'Do check between report totals
With Range("E" & Rows.count).End(xlUp).Offset(2, 0).Resize(, 5)
.FormulaR1C1 = "=R[-2]C-R[-4]C"
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlDouble
.Font.Bold = True
.HorizontalAlignment = xlCenter

End With
'Create Report Totals Check and format
ActiveCell.SpecialCells(xlCellTypeLastCell).Select
Cells(ActiveCell.Row, 1).Select
ActiveCell.End(xlUp).Select
ActiveCell.Offset(2, 2) = "Report Totals Check"

With Range(ActiveCell.Offset(2, 2), ActiveCell.Offset(2, 5))
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlDouble
.Font.Bold = True
.HorizontalAlignment = xlCenter
.NumberFormat = "#,##0.00"
End With
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,271
Members
449,219
Latest member
daynle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top