hello
i try finding code show data when i select from e1,f1,g1 and sum values the lastrow this is what i got but doesn't work
PHP Code:
Sub AAA() Dim R As Range
Dim DataRange As Range
Dim Total As Double
Dim TheYear As String
Dim TheMonth As String
Dim Theitem As String ' get your values from the linked cells.
TheYear = Range("A1").Value
TheMonth = Range("F1").Value
Theitem = Range("G1").Value
Set DataRange = Worksheets("INV").Range("A1:D10") '<< CHANGE
For Each R In DataRange.Columns(1).Cells
If R(1, 1).Value = TheYear Or LCase(Trim(TheYear)) = "ALL" Then
If R(1, 2).Value = TheMonth Or LCase(Trim(TheMonth)) = "ALL" Then
If R(1, 3).Value = Theitem Or LCase(Trim(Theitem)) = "ALL" Then
Total = Total + R(1, 4).Value
End If
End If
End If
Next R
MsgBox Total
End Sub
thanks in advance