TL;DR: SlicerCaches is a property of the Workbook object.
Sub slicer_Count()
For Each sc In ActiveWorkbook.SlicerCaches
Debug.Print (sc.SlicerItems.Count)
Next
End Sub
Your use of On Error Resume Next make the code pass over in silence the error for line:
Set slBox = wb.Sheets("Sheet").SlicerCaches("ID")
Error:
Run-time error '438':
Object doesn't support this property or method
That is a reference to wb.Sheets("Sheet"), a Worksheet object. See the documentation for SlicerCache:
Use the SlicerCaches property of the Workbook object to access the SlicerCaches collection of SlicerCache objects in a workbook.
I.e., instead of wb.Sheets("Sheet") you need:
Set slBox = wb.SlicerCaches("Slicer_ID") 'or less likely: "ID"
number = slBox.SlicerItems.Count
Note that, by default, a slicer name will be assigned like "Slicer_[Column_Name]". E.g., a slicer for column "Col A" will be named "Slicer_Col_A", and one for column "ID" will be named "Slicer_ID".
When you have slicers for similarly named columns from separate tables, excel will auto-increment: "Slicer_ID", "Slicer_ID1", etc.
Of course, you can change the name by setting slBox.Name = "ID". So, "ID" might be correct, but "Slicer_ID" seems more likely.
If you are not sure, you can either print the names in vba, or find the name of a specific slicer by selecting it, right-clicking it, and selecting "Slider Settings":
