I have the following codes
HTML Code:
Function PrjByMonth(strField As String, pMonth As Date)
Dim sht As Worksheet, i As Long, j As Integer
PrjByMonth = 0
For Each sht In ActiveWorkbook.Sheets
If Mid(sht.Name, 1, 2) = "FY" Then
For j = 3 To 14 'The row of dates. Starts at C1 to N1
If sht.Cells(1, j) = pMonth Then
For i = 2 To 30 'update with max row
If sht.Cells(i, 2) = strField Then
PrjByMonth = PrjByMonth + CDbl(sht.Cells(i, j))
GoTo nxtSht
End If
Next i
End If
Next j
End If
nxtSht: Next
End Function
Public Sub ViewPrjByMth()
Dim strField As String, pMonth As Date
Worksheets("PrjByMth").Visible = True
Sheets("PrjByMth").Activate
PrjByMonth strField, pMonth
End Sub
I attached a picture of the results that I'm getting that I just can't figure out why this line "If sht.Cells(1, j) = pMonth Then" is not giving me the correct information. Please help.
