I ask my macro to select a data range visible after a filter in multiple tabs. If there is no beach visible (which can happen), I put an On Error Goto to pass it to the next tab. This works if the error appears only once, but not both ...
Here are simplified in my line of code:
Code:
Sheets("A").select
Range("A1").Select
On Error GoTo Suite1
With Range("_FilterDatabase")
Set plagefiltervisible = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible)
With plagefiltervisible.Areas(1).Rows(1).Select
Range(Selection, Selection.End(xlDown)).Select
End With
End With
Suite1:
Sheets("B").select
Range("A1").Select
On Error GoTo Suite2
With Range("_FilterDatabase")
Set plagefiltervisible = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible)
With plagefiltervisible.Areas(1).Rows(1).Select
Range(Selection, Selection.End(xlDown)).Select
End With
End With
Suite2:
Sheets("C").select
Range("A1").Select
On Error GoTo Suite3
With Range("_FilterDatabase")
Set plagefiltervisible = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible)
With plagefiltervisible.Areas(1).Rows(1).Select
Range(Selection, Selection.End(xlDown)).Select
End With
End With
Suite3:
Sheets("D").select
Range("A1").Select
On Error GoTo Suite4
With Range("_FilterDatabase")
Set plagefiltervisible = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible)
With plagefiltervisible.Areas(1).Rows(1).Select
Range(Selection, Selection.End(xlDown)).Select
End With
End With
Suite4:
End sub
If the leaf B and C in the sheet is not visible in data, the code blocks on the line marked in BLUE.
Bookmarks