Solved

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

Posted on 2014-11-07
7
177 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

929 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now