AutoFilter not recognizing values

Reddog94

Board Regular
Joined
Dec 20, 2011
Messages
52
I have an autofilter setup with 3 values: "Show", "Hide" and "Always". The show/hide values are dependent if formulas based on other cells.

I have two sheets with this filter (Template and Summary); the filter works fine on the Template tab, however on the Summary tab...

When filtered to only show values "Always" and "Show", the filter only recognizes some of the "Show" values. I have copy pasted the if formula from the rows that work to the rows that don't and verified the formatting is the same. There are no named ranges that may be screwing it up and no empty cells in the filter range.

If I manually unhide the rows in questions, then run the filter, the rows stay shown. However, if I run the filter to only show "Always", then run it again to show "Always" or "Show", then the rows in question disappear.

I also have vba assigned objects for show and hide (the same scripts are used for the Template sheet and the Summary sheet), but the issue persists when using the buttons.

The curious thing is that if, in the rows in question, I hard code "Show" instead of it being an if formula, the filter works fine. But the formula that doesn't work is also used on rows that do work, so I'm completely stumped.

Help...please!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Please provide some more info. What version of Excel are you using, and show us the formula and code involved.
 
Upvote 0
I am working in Excel 2007.

These are the scripts, however, I don't believe it to be an issue with the script because manually auto-filtering doesn't work properly either (and the scripts work just fine in another tab that is filtering exactly the same things).

Sub ShowDetail()

ActiveSheet.Unprotect
ActiveSheet.Range("$A$6:$A$399").AutoFilter Field:=1, Criteria1:="=ALWAYS" _
, Operator:=xlOr, Criteria2:="=SHOW"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub



Sub HideDetail()

ActiveSheet.Unprotect
ActiveSheet.Range("$A$6:$A$399").AutoFilter Field:=1, Criteria1:="ALWAYS"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub
 
Upvote 0
The code in Sub ShowDetail() may have an extra "=". Look at the way this is written compared to the hide detail sub shown below.

Criteria1:="=ALWAYS"
Criteria2:="=SHOW"

Criteria1:="ALWAYS"

But, what about the If formula you were talking about?
 
Upvote 0
I thought that was weird too, but that is from a recorded macro that I just copied into my script. I did try it without the extra = sign after the left parenthesis and both ways work identically (and both with the same issue).

For the if statement, it is basically saying this:
IF(K100<>0,"SHOW","HIDE")

This formula is used in both rows that are show/hiding properly, and in the rows that are the issue. I pasted it from rows that are working properly, so know that it is identical. There are no extra spaces, funky formatting, etc.

I don't have the rights to post an attachment, otherwise I would share a screen shot.
 
Upvote 0
I wouldget rid of the extra = sign, it's not correct whether it works or not.

I'm still not clear what you are doing with the If formula. Are you using it in a column specifically setup to filter on Show or Hide (a helper column)? And where is the "Always" criteria come into play?
 
Upvote 0
Correct, column A in the sheet is the filter. It has 3 values:

Hard Coded:
"ALWAYS" - which means the row should always be shown (Sub HideDetail)

Formula Driven via the if<>0:
"HIDE" - no data is in the row, so never show it
"SHOW" - data is in the row, show it when detail is desired (Sub ShowDetail)

The filter options (in the script or manual) used are:

(1 - the HideDetail macro)
Only show if column A = "ALWAYS"

(2 - the ShowDetail macro)
Show if column A = either "ALWAYS" or "SHOW"
 
Upvote 0
Well, I've set up a sheet just like you have described and it works fine (of course). I did verify that the macro recorder puts in the extra = sign, and that it works fine without it.

The only thing left I can think of is the file type. Mine is a 2007 file type, not a .xls type. So I'm not in compatibility mode. In Excel 2007 you should be able to write the criteria like this

Criteria1:=Array("Always", "Show")

Other than that I'm stumped too, because it works for me.
 
Upvote 0
Rats. Thank you very much for the assistance.
I will keep digging and post if I figure it out.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top