Filter 2 specific columns?

laxster

Registered User.
Local time
Today, 09:29
Joined
Aug 25, 2009
Messages
145
Is it possible to allow AutoFilter arrows to only show up on two columns. I only want people to be able to filter columns E & G of a worksheet, but it seems like I can AutoFilter either one column or all of the columns. Is there code that could do this for me?
 
i'm not sure if you can, but you can certainly write code and put a combo box on top of a cell and then hide the rows with a loop that doesn't match the selection. it's a long way to go, but it will work.
 
Hi, laxster,

mark only cells E1 and F1 and call the autofilter or use
Code:
Range("E1:F1").AutoFilter
in VBA after checking about FiulterMode.

Ciao,
Holger
 
You can only autofilter a single range so you will have to rearrange your spreadsheet layout so the columns you want to autofilter are adjacent.
 
Hi, chergh,

you´re right about the adjacent columns regarding the manual use of the autofilter. But using VBA I´d take this road:

Code:
Sub ApplyAutofiterToColumns_E_And_G()

Dim rngCell As Range
Application.ScreenUpdating = False

'assuming that the Filter is to be set in the first row of the active sheet
If Not ActiveSheet.AutoFilterMode Then
  Range(Cells(1, 1), Cells(1, Cells(1, 1).End(xlToRight).Column)).AutoFilter
End If
For Each rngCell In Range(Cells(1, 1), Cells(1, Cells(1, 1).End(xlToRight).Column))
  Select Case rngCell.Column
    Case 5, 7
    Case Else
      rngCell.AutoFilter Field:=rngCell.Column, Visibledropdown:=False
  End Select
Next rngCell

Application.ScreenUpdating = True

End Sub
Ciao,
Holger
 
I like that, hiding the dropdown is nice solution.
 

Users who are viewing this thread

Back
Top Bottom