Hide Filter Arrows

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
How could I make the following code to hide all the filter arrows including the column 2?

I've applied filter to row 10. Starting from columns C to K.

Code:
Sub HideArrows()
'hides all arrows except column 2
Dim c As Range
Dim i As Integer
i = Cells(1, 1).End(xlToRight).Column
Application.ScreenUpdating = False
For Each c In Range(Cells(1, 1), Cells(1, i))
 If c.Column <> 2 Then
  c.AutoFilter Field:=c.Column, _
    Visibledropdown:=False
 End If
Next
Application.ScreenUpdating = True
End Sub
Thanks in advance.
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
10,696
Office Version
2019
Platform
Windows
Why do you need a macro to do that? You can just click the filter button in the toolbar to remove them.
 

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Because I do not want to keep the filter arrows visible but to filter the sheet with the help of another code.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
10,696
Office Version
2019
Platform
Windows
As soon as you hide the arrow on the column that is being filtered it will show the hidden rows anyway.

You need to work on the logic of

Code:
Sub hidefilter()
Application.ScreenUpdating = False
' select range not hidden by filters
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Select
' remove filter and show the hidden rows
Selection.AutoFilter
' hide everything
ActiveSheet.UsedRange.EntireRow.Hidden = True
' unhide the filter selection
Selection.EntireRow.Hidden = False
Application.ScreenUpdating = True
End Sub
I've gone with hiding then unhiding as there is no invert selection (that I can find) in excel, can probably be improved, but this is a quick test to make sure I'm on the right lines of what you need.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,813
Messages
5,513,535
Members
408,957
Latest member
Jcoverick

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top