Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50110

Filter empty, how to continue?

$
0
0
Hello!

Another, probably very easy thing, but I still dont get it how to do it. I did manage to put this code to be dynamic to my list, but I face a problem here. As this code checks the first visible cell and makes the selection, when the selection is empty, so nothing fits the criteria, then it stops. How can I make it to continue to next step?

Code:

    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$S$" & LRow).AutoFilter Field:=7, Criteria1:="="
    ActiveSheet.Range("$A$1:$S$" & LRow).AutoFilter Field:=8, Criteria1:="H7"
   
  'If these two criteria are not met, but I still want to continue, what should I write here?

    Range("G2:G" & LRow).SpecialCells(xlCellTypeVisible).Select
    ActiveCell.FormulaR1C1 = "P"
    Range("G2" & ":G" & LRow).Select
    Selection.FillDown
    Selection.AutoFilter
   
    Range("A1").Select  'Here, I just reset the selection, so the next autofilter gets properly to all columns.   
   
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$S$" & LRow).AutoFilter Field:=7, Criteria1:="="
    ActiveSheet.Range("$A$1:$S$" & LRow).AutoFilter Field:=8, Criteria1:="H4"
    Range("G2:G" & LRow).SpecialCells(xlCellTypeVisible).Select
    ActiveCell.FormulaR1C1 = "C"
    Range("G2" & ":G" & LRow).Select
    Selection.FillDown
    Selection.AutoFilter


Viewing all articles
Browse latest Browse all 50110