Hello,
The data into Drill worksheet comes from Masterdata worksheet in the same workbook and the data contains 'Risk' as a field. The Risk field includes data of Medium and High Risk for all managers.
I am hiding rows based on the Manager criteria (just like what autofilter does, but I am obliged not to use autofilter here, per instructions from my management).
so, if a person selects Mgr1, the data containing Medium and High Risk for that Mgr1 would populate into the worksheet, and the countif function counts the data based on the criteria, Medium and High:
The Problem:
If you see the code, I have written for when no data is populated, the end row is taken as 1932 (which is the last row+1 for that section), the count is taken as zero, but when data is populated and there is no data in it containing either Medium Risk or High Risk for a particular manager (when the code goes to Else part), then I get an error 1104: No cells found.
How do I overcome this error and make the count as 0?
Your help would be much appreciated.
Thank you.
The data into Drill worksheet comes from Masterdata worksheet in the same workbook and the data contains 'Risk' as a field. The Risk field includes data of Medium and High Risk for all managers.
I am hiding rows based on the Manager criteria (just like what autofilter does, but I am obliged not to use autofilter here, per instructions from my management).
so, if a person selects Mgr1, the data containing Medium and High Risk for that Mgr1 would populate into the worksheet, and the countif function counts the data based on the criteria, Medium and High:
Code:
Sheets("Drill").Activate
Range("B1734").Select
lastcell = Range("B1734").End(xlDown).Row
If lastcell = 1932 Then
Range("C1733").Value = 0
Range("E1733").Value = 0
Else
Range("E1733").Value = WorksheetFunction.CountIf(Range("O1735:O1930").SpecialCells(xlCellTypeVisible), "Medium Risk")
Range("C1733").Value = WorksheetFunction.CountIf(Range("O1735:O1930").SpecialCells(xlCellTypeVisible), "High Risk")
End If
If you see the code, I have written for when no data is populated, the end row is taken as 1932 (which is the last row+1 for that section), the count is taken as zero, but when data is populated and there is no data in it containing either Medium Risk or High Risk for a particular manager (when the code goes to Else part), then I get an error 1104: No cells found.
How do I overcome this error and make the count as 0?
Your help would be much appreciated.
Thank you.