ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoFilter method of Range class failed (https://www.excelbanter.com/excel-programming/350700-autofilter-method-range-class-failed.html)

blopreste3180

AutoFilter method of Range class failed
 
HELP QUICK!
I am trying to set an autofilter macro so when a user presses a button in a
worksheet, it automatically filters the data in a separate sheet. Here is my
code abbreviated (removed many range lines)
Selection.AutoFilter Field:=2, Criteria1:="19A"
ActiveWindow.LargeScroll ToRight:=7
ActiveWindow.ScrollColumn = 91
NOTE: (many activewindow.scrollcolumn=#'s left out)
ActiveWindow.SmallScroll Down:=3
ActiveWindow.SmallScroll ToRight:=3
ActiveWindow.SmallScroll Down:=-12
ActiveWindow.SmallScroll ToRight:=-3
Range("B53").Select
ActiveWindow.FreezePanes = True
ActiveWindow.SmallScroll ToRight:=7
Range("U53:U127").Select
Range("U127").Activate
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-74]C:R[-1]C)"
Range("U53:U127").Select
ActiveWindow.SmallScroll ToRight:=152
Range("FH53:FH127").Select
Range("FH127").Activate
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-74]C:R[-1]C)"
Range("FH53:FH127").Select
ActiveWindow.LargeScroll ToRight:=3
ActiveWindow.ScrollColumn = 192
NOTE (many activewindow.scrollcolumn=#'s left out)
Range("A53").Select

I am trying to get this button to work and am on a tight deadline, quick
help is certainly appreciated.
End Sub

gwhenning

AutoFilter method of Range class failed
 
I see a lot of activewindow, but have you ever declared your activesheet? I
see a lot of macros using ranges fail because the sheet has never been set
active.

"blopreste3180" wrote:

HELP QUICK!
I am trying to set an autofilter macro so when a user presses a button in a
worksheet, it automatically filters the data in a separate sheet. Here is my
code abbreviated (removed many range lines)
Selection.AutoFilter Field:=2, Criteria1:="19A"
ActiveWindow.LargeScroll ToRight:=7
ActiveWindow.ScrollColumn = 91
NOTE: (many activewindow.scrollcolumn=#'s left out)
ActiveWindow.SmallScroll Down:=3
ActiveWindow.SmallScroll ToRight:=3
ActiveWindow.SmallScroll Down:=-12
ActiveWindow.SmallScroll ToRight:=-3
Range("B53").Select
ActiveWindow.FreezePanes = True
ActiveWindow.SmallScroll ToRight:=7
Range("U53:U127").Select
Range("U127").Activate
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-74]C:R[-1]C)"
Range("U53:U127").Select
ActiveWindow.SmallScroll ToRight:=152
Range("FH53:FH127").Select
Range("FH127").Activate
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-74]C:R[-1]C)"
Range("FH53:FH127").Select
ActiveWindow.LargeScroll ToRight:=3
ActiveWindow.ScrollColumn = 192
NOTE (many activewindow.scrollcolumn=#'s left out)
Range("A53").Select

I am trying to get this button to work and am on a tight deadline, quick
help is certainly appreciated.
End Sub



All times are GMT +1. The time now is 06:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com