PDA

View Full Version : [SOLVED] VBA Autofilter call does not work



sflowers
11-14-2011, 04:34 PM
I am having the most ridiculous problem, but I cannot get a VBA autofilter call to work to save my life! I can manually execute the filter in question, but when I run the following


Sub LocationFilter()
MsgBox (ActiveSheet.Name)
ActiveSheet.Range("A:M").AutoFilter Field:=2, Criteria1:="802"
End Sub

absolutely nothing happens. Sheet is unprotected, data format is general......Any suggestions?

So for an overview, I just recorded the following with the auto record feature


Sub Macro2()
' Macro2 Macro
ActiveSheet.Range("$A$1:$O$136267").AutoFilter Field:=4, Criteria1:="7"
End Sub

I then cleared the filter on the sheet and re-executed the macro, nothing happened. WTF?

Trebor76
11-14-2011, 04:47 PM
For reference - cross posted (also without tags) here (http://www.excelforum.com/excel-programming/801334-vba-autofilter-call-not-working.html)

sflowers
11-14-2011, 04:59 PM
For any future users, I was missing a line of code in order to engage the filter (when I recorded macro filter was already in place)

>>Selection.Autofilter