Hi. My code below will not clear the contents in hidden rows. When a filter is applied some rows are hidden and the code only clears the contents for rows that are visible. What am I doing wrong? Surely the solution is not turn the filter off before clearing contents. Thanks.
VBA Code:
Sub ClearAll()
Dim Config As Long
Dim Ans As Integer
If WorksheetFunction.CountA(Range("A3:A10000")) = 0 Then
MsgBox "Error: No products selected."
Else
Config = vbYesNo + vbQuestion + vbDefaultButton2
Ans = MsgBox("Are you sure you want to clear all?", Config)
If Ans = vbYes Then
ActiveSheet.Unprotect Password:="Test"
Worksheets("Sheet1").Range("A3:A10000").ClearContents
ActiveSheet.Protect Password:="Test"
End If
End If
End Sub