Error 400 on running Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top