Link to home
Start Free TrialLog in
Avatar of Kathtg
Kathtg

asked on

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

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?
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Kathtg
Kathtg

ASKER

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
Avatar of Kathtg

ASKER

oh, sorry missed the top answer 0 imnorie.  Testing it now, thanks
Avatar of Kathtg

ASKER

well, ho molie, it was typo!!  doh, too many formulas in these small cells.  Thank you!
Avatar of Kathtg

ASKER

Thank you
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