HORIZONTAL FILTER

arnoldmiranda

Board Regular
Joined
Jul 15, 2002
Messages
233
Hi,
Is it possible to write a macro which can enable me to create a horizontal filter in excel

rgds
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You don't have to write it, just record it. Turn on the recorder (Tools>Macro>Record New Macro), hide the columns that you want, turn off the recorder and, optionally, assign the macro to a button.

Don't forget to also record another macro to unhide the columns.
 
Upvote 0
Hi,

Do you want to compare all values in a row to a certain cell in that row ? That's how I feel this question.
Comparing with the first cell makes sense, but if you have some headers in column A, it could be column B or even another, hence the choice...
Code:
Option Explicit

Sub horizontal_filter()
'Erik Van Geit
'060910

Dim LC As Integer           'Last Column
Dim R As Long
Dim i As Integer
Dim FilterValue As String

Const FilterColumn = 1      '1 is most logical value but you may change this

R = ActiveCell.Row
LC = Cells(R, Columns.Count).End(xlToLeft).Column

FilterValue = Cells(R, FilterColumn)

Application.ScreenUpdating = False

    'to filter starting after FilterColumn
    For i = FilterColumn + 1 To LC
    'to filter all columns even before the filtercolumn
    'For i = 1 To LC
        If i <> FilterColumn Then
        Columns(i).Hidden = Cells(R, i) <> FilterValue
        End If
    Next i

Application.ScreenUpdating = True

End Sub
kind regards,
Erik
 
Upvote 0
Hi,
Thanks guys, what I was aiming for is a filter like in the filter we have in Data Filter > Auto Filter instead of it targetting colums can it target rows. Basically the same thing that happends vertically I was wondering if we could see it horizontally

rgds
 
Upvote 0
A bad idea is transposing your data to show vertically.
 
Upvote 0
Hi,
Thanks guys, what I was aiming for is a filter like in the filter we have in Data Filter > Auto Filter instead of it targetting colums can it target rows. Basically the same thing that happends vertically I was wondering if we could see it horizontally

rgds
you started with
Is it possible to write a macro which can enable me to create a horizontal filter in excel
did you try out my suggestion ?
 
Upvote 0
Hi,
Yes and it works too, I was just wondering if the horizontal option was possible through an macro or ad-in feature

rgds
 
Upvote 0

Forum statistics

Threads
1,222,040
Messages
6,163,554
Members
451,844
Latest member
ddnndd1234

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