"SUM" function code

Sebastian

New Member
Joined
Sep 17, 2002
Messages
32
Hi,
I'm trying to write a code that will add the values of a range of cells. The range will always be in column E. It will always start in the cell E8 and finish on the last used cell in that column. The sum is meant to be displayed in the cell below last.
Sounds simple enough, doesn't it?
This is what I've got:

Sub AddValues()
Range("E65536").End(xlUp).Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=Sum(E8:R[-1]C)"
End Sub

Every time I run the macro an apostrophe gets added on each side of E8 (it becomes 'E8') and an error comes up.

Any advise on how to overcome this?
Please.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

plettieri

Well-known Member
Joined
Sep 4, 2002
Messages
1,556
Platform
  1. MacOS
Are there any empty cells in the range in which you wish to add?
 

Sebastian

New Member
Joined
Sep 17, 2002
Messages
32
No there are no empty cells. There may be some with the 0 value but they're not empty.
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,257
Try this instead:

Sub AddValues()
Range("E65536").End(xlUp).Offset(1, 0).Value = _
WorksheetFunction.Sum(Range("E8", Range("E8").End(xlDown)))
End Sub
 

Sebastian

New Member
Joined
Sep 17, 2002
Messages
32
On 2002-09-30 22:57, Tom Urtis wrote:
Try this instead:

Sub AddValues()
Range("E65536").End(xlUp).Offset(1, 0).Value = _
WorksheetFunction.Sum(Range("E8", Range("E8").End(xlDown)))
End Sub

It works well. Thank you Tom.
 

Forum statistics

Threads
1,143,641
Messages
5,719,988
Members
422,257
Latest member
Calion

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
Top