Question : Sum range for all worksheets starting with a specifc name

In Worksheet.Name of "Main" in cell "K1", I need a formula that will give me the sum of all ranges A11:B12 on all worksheets with a name like "Series*".  

If my sheet names for "Series" remained static, I could use a formula like this:
=SUM(Series1_AA:Series9_AA!A11:B12)+SUM(SeriesA_AA:SeriesZ_AA!A11:B12)

But the problem is, these sheet names change regularly.  So one day my formula may need to be:
=SUM(Series1_BB:Series9_BB!A11:B12)+SUM(SeriesA_BB:SeriesZ_BB!A11:B12) OR
=SUM(Series1_CC:Series9_CC!A11:B12)+SUM(SeriesA_CC:SeriesZ_CC!A11:B12)

The one thing that remains consistent is the "Series" portion of the name.  I'm guess there a way that this can be done through VBA.  I'm open to any suggestions.  Thanks!



Answer : Sum range for all worksheets starting with a specifc name

Put this formula where you want the result

=SeriesSum(AA11:B12)


And create this VBA Function

Function SumSeries(myRange As Range) As Variant
Dim rStr As String
Dim sh As Worksheet

rStr = myRange.Address

For Each sh In ThisWorkbook.Worksheets
    If Left(sh.Name, 6) = "Series" Then SumSeries = SumSeries + Application.WorksheetFunction.Sum(sh.Range(rStr))
Next sh

End Function

Random Solutions  
 
programming4us programming4us