Unfilter only the active column

GuruPepsi

New Member
Joined
May 8, 2016
Messages
4
Dear Forum members

Looking for some help here, I am relatively new to VBA so this might be elementary for some of you, although I do not know how to do it

I have a large Excel spreadsheet with about 6000+ rows and 25+ columns
I have filtered all the column headings using Data > Filter

For analysis, I often filter the spreadsheet on several columns based on search criteria.

Sometimes I want to UnFilter only one column - the active one that my selected cell is at.

I know I can do that by clicking the filter drop down for that heading and checking "Select All", but that is several clicks and slows me down

I was wondering if there is a VBA macro so I can create a button on my Quick Access Toolbar so whenever I click it, the column of the active cell gets unfiltered without disturbing any of the filters on the remaining columns.

I did a Google search and there are several suggestions in many Excel forums, but they all require a specific column to be called out (Field:6, for example) for unfiltering as part of the code

I work with several spreadsheets, with similar analysis. Not always I want to unfilter the same column and not always are the spreadsheets the same.

Basically what I am looking for is a VBA macro that first identifies the column of my active cell, then if that column is filtered, it executes a "Select All" command on that column only. I can then create a button on the QAT and link it to that macro.

Thanks in advance for support
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

jorismoerings

Well-known Member
Joined
Jul 4, 2014
Messages
1,284
Hi,

Try this:

Code:
<code>Sub RemoveActiveFilter()

Dim FilterNum As Long
Dim FilterRange As Range

Set FilterRange = ActiveCell.CurrentRegion

If Not Intersect(ActiveCell, FilterRange) Is Nothing Then
    FilterNum = Intersect(ActiveCell, FilterRange).Column - FilterRange.Column + 1
    FilterRange.AutoFilter Field:=FilterNum
End If

End Sub</code>
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,114,117
Messages
5,546,038
Members
410,721
Latest member
adi772
Top