I was hoping someone could help with this code, is it possible to modify the "ArgList" to include sheet names that are represented by a number which is at least 6 characters? I want to include all newly added sheets even though I'm not sure how many might be added.
Option Explicit
Function SUMIF3D( _
CritRng As Range, _
Crit As Variant, _
SumRng As Range, _
ParamArray ArgList() As Variant)
Dim Arg As Variant
Dim wkb As Workbook
Application.Volatile
If IsMissing(ArgList) Then
SUMIF3D = CVErr(xlErrValue)
Exit Function
End If
Set wkb = Application.Caller.Parent.Parent
For Each Arg In ArgList
SUMIF3D = SUMIF3D + _
WorksheetFunction.SumIf(wkb.Sheets(Arg).Range(CritRng.Address), _
Crit, wkb.Sheets(Arg).Range(SumRng.Address))
Next Arg
End Function
Option Explicit
Function SUMIF3D( _
CritRng As Range, _
Crit As Variant, _
SumRng As Range, _
ParamArray ArgList() As Variant)
Dim Arg As Variant
Dim wkb As Workbook
Application.Volatile
If IsMissing(ArgList) Then
SUMIF3D = CVErr(xlErrValue)
Exit Function
End If
Set wkb = Application.Caller.Parent.Parent
For Each Arg In ArgList
SUMIF3D = SUMIF3D + _
WorksheetFunction.SumIf(wkb.Sheets(Arg).Range(CritRng.Address), _
Crit, wkb.Sheets(Arg).Range(SumRng.Address))
Next Arg
End Function