After applied the advance filter, I sum only the visible cells by using the code below and it functions well. However, it shows error when there is no visible cell after the filter. Any idea on how to cover the error?
Sub sum ()
Sheets("Sheet1").Select
x = cells(Rows.Count, 8).End(xlUp).Row
Sheets("Tax Invoice").Range("M55") = WorksheetFunction.Sum(Range("H7:H" & x).SpecialCells(xlCellTypeVisible))
End sub
Count the number of visible rows before attempting to calculate the sum:
Also, you should not use a native function name for your functions:
Sub sum()