Solved

how to call Sum function from cell in workbook and refresh on any change

Posted on 2014-11-07
7
182 Views
Last Modified: 2014-11-07
Hello,

I have multiple sheets in a workbook.  On a few of the sheets, I want to sum the value in F3.  I want the sum to appear on a specific sheet titled and location and be an automatic update if the values in any of the sheets change.  

I have this function in the Module of the workbook:
Function SumSeries(SumRange As Range) As Double
Dim ws As Worksheet
Dim TopTotals As Double
     
    TopTotals = 0
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name <> "Metrics" And ws.Name <> "TFSData" And ws.Name <> "TFSBugs" Then
            TopTotals = TopTotals + WorksheetFunction.Sum(ws.Range(sum_Range.Address))
        End If
    Next ws
    SumSeries = TopTotals
   
 
End Function

I have tried placing variations in the cell like =SumSeries($F3) but I get #VALUE.   How do I structure what should be in the cell formula to call the function, and have it automatically update when any value within the Sum is updated?
0
Comment
Question by:Kathtg
  • 4
  • 2
7 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 40428606
Try this.


            TopTotals = TopTotals + WorksheetFunction.Sum(ws.Range(SumRange.Address))
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40428680
Is there any reason why you don't just use:

=SUM(Sheet1!F3,Sheet2!F3,Sheet3!F3)   amending sheet names appropriately.

if some of the sheets are in sequence and there is no risk that sheets could be inserted that you do not wish to include:

=SUM('Sheet1:Sheet3'!F3,Sheet5!F3)

Thanks
Rob H
0
 

Author Comment

by:Kathtg
ID: 40428686
Each tester has a separate workbook that has an automatic copy button.  It deletes the sheet and replaces it with the newer version.  When this is done, the reference is lost.  I was looking into not deleting the sheet with replacement but 1.  I couldn't figure it out.   2.  we will have any number of testers and workbooks for each project so I thought making these sums dynamic will be the best route
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:Kathtg
ID: 40428690
oh, sorry missed the top answer 0 imnorie.  Testing it now, thanks
0
 

Author Comment

by:Kathtg
ID: 40428694
well, ho molie, it was typo!!  doh, too many formulas in these small cells.  Thank you!
0
 

Author Closing Comment

by:Kathtg
ID: 40428697
Thank you
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40428702
If the sheets are sequential, set a couple of blank sheets called Start and Finish and make sure that all sheets required for the Sum are in between these two.

The sum would then be:

=SUM(Start:Finish!F3)

There is then no reference to specific sheets that will get lost .

Thanks
Rob H
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question