Hi,
You could do this
Function GetInfo()
Dim lookupVal As String, TotalSales As Double, PendingSaleAmt As Double
Dim cell As Range
lookupVal = "Blue"
With Sheets("Data")
With .ListObjects("DataInfo").Range
.AutoFilter
.AutoFilter Field:=1, Criteria1:=lookupVal
.AutoFilter Field:=5, Criteria1:=">=01/01/2017", Operator:=xlAnd, Criteria2:="<=02/01/2017"
TotalSales = Application.WorksheetFunction.Subtotal(103, .Columns(3)) - 1
For Each cell In Sheets("Data").Range("D:D").SpecialCells(xlCellTypeVisible).Cells
If IsNumeric(cell.Value2) And cell.Value2 <> 0 Then
PendingSaleAmt = cell.Value2
Exit For
End If
Next cell
'Need this to print 3,400
Debug.Print TotalSales
'Need this to print first non null or 0 value
'Need this to print 100
Debug.Print PendingSaleAmt
End With
End With
End Function
Bookmarks