You can use this user-defined function to accomplish what you need.
This formula goes into a cell on your summary sheet:
=SumSalaries( "5/15/2005", "Sum1", "Sum3", "A1", "B1" )
Instead of literal values in quotation marks, you could also refer to cells
on your summary sheet that contain the corresponding values.
"5/15/2005" is the desired date.
Sum1 & Sum3 are the first and last of the individual sheets, respectively.
All other individual sheets must be between Sum1 & Sum3.
A1 is the address that contains the date on each individ. sheet. B1 is the
address to sum.
Put this code into a module in VBA:
Public Function SumSalaries(strCheckDate As String, strSheetStart As String,
strSheetEnd As String, strAddressCheck As String, strAddressSum As String) As
Double
Application.Volatile
Dim wkb As Workbook
Dim wks As Worksheet
Dim lngStart As Long
Dim lngEnd As Long
Dim i As Long
Dim dblTotal As Long
Set wkb = ThisWorkbook
If (Not (ExcelSheetExists(wkb, strSheetStart))) Then
Call MsgBox("Sheet (" & strSheetStart & ") does not exist!")
Exit Function
End If
If (Not (ExcelSheetExists(wkb, strSheetEnd))) Then
Call MsgBox("Sheet (" & strSheetEnd & ") does not exist!")
Exit Function
End If
lngStart = wkb.Worksheets(strSheetStart).Index
lngEnd = wkb.Worksheets(strSheetEnd).Index
strCheckDate = Format(strCheckDate, "mm/dd/yyyy")
dblTotal = 0
For i = lngStart To lngEnd
Set wks = wkb.Worksheets(i)
If (Format(wks.Range(strAddressCheck).Value, "mm/dd/yyyy") =
strCheckDate) Then
dblTotal = dblTotal + wks.Range(strAddressSum).Value
End If
Next i
SumSalaries = dblTotal
Set wkb = Nothing
End Function
Public Function ExcelSheetExists(wkb As Workbook, strSheet As String) As
Boolean
Dim wks As Worksheet
On Error GoTo ErrHandler
Set wks = wkb.Worksheets(strSheet)
ExcelSheetExists = True
Exit Function
ErrHandler:
ExcelSheetExists = False
End Function