There were some inconsistencies with UC/LC (MAY - may) and variable types (string -vs double)
Capture.JPG
This should fix it
Option Explicit
Option Compare Text
Sub GetTotal()
Dim iRow As Long
Dim Total As Double
Dim TheYear As Variant, TheMonth As Variant
Dim Theitem As String
With ActiveSheet
' get your values from the linked cells.
TheYear = Trim(.Range("E1").Value)
TheMonth = Trim(.Range("F1").Value)
Theitem = Trim(.Range("G1").Value)
For iRow = 2 To .Cells(1, 1).CurrentRegion.Rows.Count
If CStr(.Cells(iRow, 1).Value) = TheYear Or TheYear = "all" Then
If .Cells(iRow, 2).Value = TheMonth Or TheMonth = "all" Then
If .Cells(iRow, 3).Value = Theitem Or Theitem = "all" Then
Total = Total + .Cells(iRow, 4).Value
End If
End If
End If
Next iRow
.Cells(1, 4).End(xlDown).Offset(1, 0).Value = Total
End With
End Sub
Edit - added total to last row