summing up values in an excel spreadsheet
Could some one tell me which method i could use to sum up values in certain
columns in an excel spreadsheet.
Note that these excel spreadsheets are created dynamically .
Thanks in advance
Re: summing up values in an excel spreadsheet
By 'created dynamically', I assume you don't know how many cells/columns
you'll be dealing with. The basic tool for this problem is the CurrentRegion
property of the Range object. It will scan adjacent cells of a particular
cell and return a range with all cells around it with values in them. (Try
it out with CTRL-SHIFT-* to see what I mean). I've put together a general
purpose function that takes a single cell as parameter and returns the sum
of all cells in the original cell's CurrentRegion (should work fine for columns
'Sums all cells in the 'current region' of the cell regerneced by
'the parameter Rng
Public Function SumRange(ByVal Rng As Range) As Double
Dim Cell As Range
Dim Sum As Double
Set Rng = Rng.CurrentRegion
For Each Cell In Rng
Sum = Sum + Cell.Value
SumRange = Sum
>Could some one tell me which method i could use to sum up values in certain
>columns in an excel spreadsheet.
>Note that these excel spreadsheets are created dynamically .
>Thanks in advance
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL