Avatar of Lambel
Lambel

asked on 

excel vba sum a range of cells on another sheet

I am trying to do something I thought would be fairly simple, but is causing me quite a bit of headache!  I need to use vba to go to a sheet in an open workbook, start at the top of the data, (usually row 2), select all the data in the column and insert a sum at the bottom.  This is really easy to do manually, but I can't get the code to reproduce it.  

'totals
        Dim nextCell As Variant
        Range("C1").Select
        Selection.End(xlDown).Select
        nextCell = ActiveCell.Offset(1, 0).Row
        nextCell.Select
        
        ActiveCell.FormulaR1C1 = "=SUM(R[-832]C:R[-1]C)"

Open in new window

Microsoft Excel

Avatar of undefined
Last Comment
Lambel
ASKER CERTIFIED SOLUTION
Avatar of jppinto
jppinto
Flag of Portugal image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Lambel
Lambel

ASKER

Sweet! Worked great.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo