ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autofilter (https://www.excelbanter.com/excel-programming/372181-autofilter.html)

Geebee

autofilter
 
hi,

I am getting the following error message:

runtime error 1004 unable to get the autofilter property of the range class

as a result of the following code:

Sheets("NewBKInput").Visible = True
Sheets("NewBKInput").Activate
Sheets("NewBKInput").Select

'sort the month column before selecting the oldest month
If Selection.AutoFilter = True Then
Selection.AutoFilter 'turn off autofilter option
End If

How can I fix this? I do not understand why the following code (which
appears above the code above) works fine:

Sheets("Input1").Visible = True
Sheets("Input1").Activate
Sheets("Input1").Select


'sort the month column before selecting the oldest month
If Selection.AutoFilter = True Then
Selection.AutoFilter 'turn off autofilter option
End If
Columns("A:O").Select

Thanks in advance,
geebee




All times are GMT +1. The time now is 12:19 AM.

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