Hi, what do I need to add to the below code to only count the visible data after filtering. I assume it is possibly .SpecialCells(xlCellTypeVisible) or similar after With Worksheet("calculations"), but I can't figure it out. Help appreciated.
Sub Count_only_visible_data()
With ActiveSheet
.Range("E5").Value = Countv("Work", "WSCA1", "Processed")
.Range("E6").Value = Countv("Work", "WSCA2", "Processed")
.Range("E7").Value = Countv("Work", "SECA11", "Processed")
.Range("E8").Value = Countv("Work", "SECA12", "Processed")
.Range("E9").Value = Countv("Work", "SECA13", "Processed")
.Range("E17").Value = Countv("Work", "NWCA5", "Processed")
.Range("E18").Value = Countv("Work", "NWCA6A", "Processed")
.Range("E19").Value = Countv("Work", "NWCA6B", "Processed")
.Range("E20").Value = Countv("Work", "NWCA7", "Processed")
.Range("E21").Value = Countv("Work", "NWCA8", "Processed")
.Range("E22").Value = Countv("Work", "NWCA9", "Processed")
.Range("E23").Value = Countv("Work", "NWCA10A", "Processed")
.Range("E24").Value = Countv("Work", "NWCA10B", "Processed")
.Range("E32").Value = Countv("Work", "WSCA3", "Processed")
.Range("E33").Value = Countv("Work", "WSCA4", "Processed")
.Range("E34").Value = Countv("Work", "SECA14", "Processed")
.Range("E35").Value = Countv("Work", "SECA15", "Processed")
.Range("E36").Value = Countv("Work", "SECA16", "Processed")
End With
End Sub
Function Countv(v1 As String, v2 As String, Optional v3 As String = "") As Long
 Dim rng1 As Range, rng2 As Range, rng3 As Range
 With Sheets("calculations")
 
 Set rng1 = .Range("D7:D100000")
 Set rng2 = .Range("L7:L100000")
 Set rng3 = .Range("M7:M100000")
 If Len(v3) > 0 Then
 Countv = Application.CountIfs(rng1, v1, rng2, v2, rng3, v3)
 Else
 Countv = Application.CountIfs(rng1, v1, rng2, v2)
 End If
 End With
End Function