Can I get the Autofilter to work automatically without

Closed
Matt - Jan 6, 2016 at 11:33 AM
 Matt - Jan 6, 2016 at 12:41 PM
I have the following which is filter my data based on a cell:

Private Sub Worksheet_selectionchange(ByVal Target As Range)
If (Intersect(Target, Range("T4")) Is Nothing) _
Then
Exit Sub
End If
Cells.AutoFilter Field:=1, Criteria1:="=" & Range("T4")
End Sub

However, the cell it is using T4 updates when another cell is changed, and the autofilter won't update until you hover your curser over T4. Is there a way to make the autofilter update immediately without having to hover?

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jan 6, 2016 at 12:06 PM
then why not make selection off that cell.
0
Maybe I wasn't clear (and the originating cell is from a drop box) - I want an autofilter to run automatically once a cell is changed. Here is more code that does the same thing:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

ActiveSheet.AutoFilterMode = False
Range("A40:K1580").AutoFilter
Range("A40:K1580").AutoFilter Field:=1, Criteria1:=Range("T4")


End Sub

However, my problem is that my range cell, T4, updates from another worksheet based on a vlookup. Once that is cell T4 is changed, the autofilter will not run, until I put the cursor on cell T4. I would like the autofilter to run as soon as the cell changes, and not require the user to hover over the cell to make it VBA run to make the change. I tried making the change to the drop box field, and it still makes me hover over it once the drop box selection is made. Does that make sense?

Thanks for your help.
0
Actually - it does run not only if you hover over on cell T4, but it basically requires you to click on the worksheet field any of them to make it run. I was hoping it would just go automatically.
0