I'm working on a VB code where I use an autofilter. I want to clear a selection in a couple of columns, where the value in the autofilter = 1.
This is the code:
Dim lRow1 As Long lRow1 = WorksheetFunction.Max(Range("A65536").End(xlUp).Row) Rows("1:1").Select Selection.AutoFilter Selection.AutoFilter Field:=9, Criteria1:="1" Range("F2:H" & lRow1,"J2:J" & lRow1).SpecialCells(xlCellTypeVisible).Select Selection.ClearContents
Sometimes there is no value = 1, which results in clearing row no.1 because this row was still selected for the autofilter.
I'd like to be able to check if there are any visible cells, before I proceed with the clearing of the selection.
I tried this:
But this doesnt work, because row no.1 is still selected.
Can I use an If then statement to check If there are any visible cells, then clear these, if not, resume next.
Thanks in advance.