ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error 400 on running Macro (https://www.excelbanter.com/excel-programming/362683-error-400-running-macro.html)

James T

Error 400 on running Macro
 
I have created a little macro that:

1) Goes to a specific sheet;
2) Unhides a certain range of cells;

This small macro works well for me.

Coding is:

Sub Yr1unhide()
Sheets("Data").Select
Application.Goto Reference:="Year1"
Selection.EntireColumn.Hidden = False
End Sub

However I then tried to add in a filter so that only rows that have a value
of "1" in the filter column (ES) are shown. But now when I run the macro a
error box pops up with a value of 400 in it, and no other information.

Sub Yr1unhide()
Sheets("Data").Select
Application.Goto Reference:="Year1"
Selection.EntireColumn.Hidden = False
Range("ES2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=1", Operator:=xlAnd
End Sub

Can anyone help?
Regards

James

[email protected]

Error 400 on running Macro
 
I think you cannot hide/unhide a column once a filter has been applied.
This is an Excel limitation. Try removing the filter before.

Regards,
Karim


[email protected]

Error 400 on running Macro
 
I think you cannot hide/unhide a column once a filter has been applied.
This is an Excel limitation. Try removing the filter before.

Regards,
Karim



All times are GMT +1. The time now is 02:44 PM.

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