Announcement

Collapse
No announcement yet.

Filter based on ActiveCell row and column address

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Filter based on ActiveCell row and column address



    Code below applies filter to show only TRUE results, but it's tied to row 2 and column M
    Need a way to have this code be flexible by reading ActiveCell row and column address, not be hard-coded to M2

    Code:
    Sub ShowTRUE()
    With ActiveSheet
        lastRow = .Cells(.Rows.Count, 13).End(xlUp).Row
        .Range("A2:M" & lastRow).AutoFilter Field:=13, Criteria1:="TRUE"
    End With
    End Sub

  • #2
    If you have blank rows, then you need the lastrow bit. If none then to filter 2 columns to the right:
    Code:
    ActiveCell.AutoFilter ActiveCell.Offset(, 2).Column, True

    Comment


    • #3
      No blank rows
      Not looking to offsetting from ActiveCell, rather for filter to be in ActiveCell

      Comment


      • #4
        Code:
         
         ActiveCell.AutoFilter ActiveCell.Column, True

        Comment


        • #5
          Thanks, that works

          My mod below doesn't...

          Trying to filter on greater than zero

          Code:
          ActiveCell.AutoFilter ActiveCell.Column, >0

          Comment


          • #6


            Code:
            ActiveCell.AutoFilter ActiveCell.Column, ">0"

            Comment

            Working...
            X