0

I have a code below.

Sub step_9()
    Worksheets("sap_input").Activate
    Range("tbl_sap_input[#All]").AdvancedFilter Action:=xlFilterInPlace, _
        CriteriaRange:=ActiveWorkbook.Sheets("ex_types").Range("B25:B" & Range("B" & Rows.Count).End(xlUp).Row), Unique:=False
End Sub

So, once I change .Range("B25:B" & Range("B" & Rows.Count).End(xlUp).Row) to .Range("B25:B37"), everything works fine.

Can you please advise, how to fix?

GSerg
  • 76,472
  • 17
  • 159
  • 346
Alex_D.
  • 1
  • 5
  • I think it is coming from the unqualified range reference in `End(xlUp)` part which should be : `ActiveWorkbook.Sheets("ex_types").Range("B25:B" & ActiveWorkbook.Sheets("ex_types").Range("B" & Rows.Count).End(xlUp).Row)`. – shrivallabha.redij Jan 08 '20 at 12:30
  • First thing that would come to mind is that `Range("B" & Rows.Count).End(xlUp).Row)` is an implicit reference to the `ActiveSheet`, which at that time is `Worksheets("sap_input")`. You probably want to work with explicit sheet references, even better would be to use variables (and avoid things like `.Activate`) – JvdV Jan 08 '20 at 12:30

0 Answers0