Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:05:39+00:00 2026-06-04T05:05:39+00:00

The autofilter is sorting data vertically, but I want to filter rows horizontally. Lets

  • 0

The autofilter is sorting data vertically, but I want to filter rows horizontally.
Lets say that I have the following table:

1 2 2 1 2

B A E F F

B D E F F

C D E F F

What I can do is to set an autofilter and filter only the rows containing “B” in the first column. What I would like to do is to filter only the rows that contain “2” (in this case the rows are second, third and the last in this case).

I have found some information regarding this matter. All of the answers I found are containing some macros to get the job done, but they were written for MS Excel, and are not compatible with OpenOffice

For example, this macros should get the rows filtered, but is not working in OpenOffice Calc:

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

Any help is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:05:40+00:00Added an answer on June 4, 2026 at 5:05 am

    You can’t, under the assumption of reasonable expense. It’s much easier just to transform your data so that rows get columns and vice versa. So, i would strongly recommend transforming the data using Paste Special together with the Transpose option. You could even do this dynamically by using the TRANSPOSE() function.

    EDIT:

    Now i got it – you want to hide columns based on a certain value. This is possible using a macro in fact, so my first answer was incorrect – sorry for that! There are some macros around that will do this for you. You can combine such a solution with an auto filter. Here’s a solution by king_026 from the OpenOffice.org forums (slightly adapted to table structure – see below):

    REM  *****  BASIC  *****
    sub hide
       rem ----------------------------------------------------------------------
       rem define variables
       dim document   as object
       dim dispatcher as object
       rem ----------------------------------------------------------------------
       rem get access to the document
       document   = ThisComponent.CurrentController.Frame
       dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    
       rem get the current column
       nCol = ThisComponent.CurrentSelection.CellAddress.Column
    
       rem set the properties for moving right
       dim args2(1) as new com.sun.star.beans.PropertyValue
       args2(0).Name = "By"
       args2(0).Value = 1
       args2(1).Name = "Sel"
       args2(1).Value = false
    
       rem make thecurrent column counter
       dim cCol as integer
       CCol = 0
    
       rem goto the first column
       dim args1(0) as new com.sun.star.beans.PropertyValue
       args1(0).Name = "ToPoint"
       args1(0).Value = "$A$2"
    
       dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
    
       rem loop until you get back to the selected cell
        Do Until cCol > nCol
    
        rem hide if the cell value is 1
            if ThisComponent.CurrentSelection.string <> "" and ThisComponent.CurrentSelection.value = 1 then
    
                rem ----------------------------------------------------------------------
                dispatcher.executeDispatch(document, ".uno:HideColumn", "", 0, Array())
    
            End if
    
            rem goto the right nad increment the column counter
            dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args2())
            cCol = cCol + 1
    
        Loop
    
    End sub
    

    So, the following table:

    calc1

    will look like this after Autofilter on Col1 and after the macro did his work:

    calc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have AutoFilter in place in my sheet. I want to sort data using
at the moment, I have a very large spreadsheet (40k+ rows), the data includes
I have written a macro that searches through workbook and applies an autofilter to
I have the following filter for one of my profile: filter type: Include Pattern
I have two worksheets, one which is used to filter the other. Using VBA
I have some code that autofilters a worksheet based on either the first criteria,
I want to put text into a field that has been autofilled. The traditional
I can set up an autofilter using pyWin32, but I wondered if it's possible
So, in a Workbook, I have two worksheets: One has a table full of
I want to have a ComboBox in the header cells of my GridView (currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.