+ Reply to Thread
Results 1 to 9 of 9

Auto Filter by Row Number

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-31-2009
    Location
    Lincoln, USA
    MS-Off Ver
    Excel 2007 and excel 2010
    Posts
    142

    Auto Filter by Row Number

    Hello - I've searched everywhere and can't find the answer.

    Long and short is I want to code to Auto filter but use row numbers instead of text value.

    For Example with the below instead of filtering field 8 by value "Sch" I'd want to filter to show row 5

    HTML Code: 
    in the end I want to input the rows in another tab and have it filter the table to show only these rows.
    Last edited by fireguy7; 12-14-2020 at 06:55 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,465

    Re: Auto Filter by Row Number

    Just hide the rows? This hides all the Used rows, and makes just row 5 visible.

    If you want to count or sum or work with the data in the Visible row(s), extend the Macro to work on Visible Rows only.

    [Code]
    Option Explicit
    Dim f As Long

    Sub hiderows()

    'Find last row in sheet

    With Sheet1
    f = .Cells(.Rows.Count, "A").End(xlUp).Row
    If f < 2 Then f = 2

    .Rows("2:" & f).EntireRow.Hidden = True
    .Rows("5:5").EntireRow.Hidden = False

    End With

    End Sub
    Attached Files Attached Files
    Last edited by Ochimus; 12-14-2020 at 02:50 PM.

  3. #3
    Forum Contributor
    Join Date
    07-31-2009
    Location
    Lincoln, USA
    MS-Off Ver
    Excel 2007 and excel 2010
    Posts
    142

    Re: Auto Filter by Row Number

    Really close - long and short is I use excel to generate a list to import into another system. When I get failures it only tells me the row number the data that failed is on. So i need to be able to put these row numbers in another tab and filter/hide anything but these row numbers so I can move this data off of the import sheet.

    I've reattached your sheet and add a tab with the row numbers that i need to remain visible.

    using auto filter or hiding the rows doesn't make much a difference as long as I can use .SpecialCells(xlCellTypeVisible) to grab the data after.
    Attached Files Attached Files

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Auto Filter by Row Number

    Why don't you upload a sample file depicting your actual file setup and tell us what you want to do with the grabbed data...perhaps there is a simplistic solution available...
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  5. #5
    Forum Contributor
    Join Date
    07-31-2009
    Location
    Lincoln, USA
    MS-Off Ver
    Excel 2007 and excel 2010
    Posts
    142

    Re: Auto Filter by Row Number

    I really appreciate all the help! I'll try but I'm dealing with sensitive information so have to be careful. Given this I've mocked up as close to the live version that I can supply.

    Data Tab = Original data set
    Error Rows = exact what I get after doing the initial import
    End Desire Results = what I'm looking to get to.

    Hope this helps

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Auto Filter by Row Number

    Sub sintekJ3v16()
    Dim Arr, Rw
    Rw = Join(Application.Transpose(Sheet3.Range("A2", Sheet3.Range("A" & Rows.Count).End(xlUp)).Value), ","): Rw = Split(Rw, ",")
    With Sheet1.Cells(1).CurrentRegion
        Arr = Application.Index(.Value, Rw, Application.Evaluate("row(1:" & .Columns.Count & ")"))
    End With
    Sheet2.Range("A2").Resize(UBound(Arr, 2), UBound(Arr, 1)) = Application.Transpose(Arr)
    End Sub
    Last edited by Sintek; 12-14-2020 at 05:09 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,465

    Re: Auto Filter by Row Number

    fireguy,

    Can you just clarify the requirement, please?

    Your End Desired Results and Data Sheets have highlighted rows three and eight, but the Error Rows sheet says rows three and seven?

    And what criteria makes something an "Error row", as the content seems to be the same structure in all your sample rows?

    Ochimus

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Auto Filter by Row Number

    Quote Originally Posted by fireguy7 View Post
    in the end I want to input the rows in another tab and have it filter the table to show only these rows.
    Try
    Sub test()
        Dim r As Range
        With Sheets("data").Cells(1).CurrentRegion
            Set r = .Offset(, .Columns.Count + 2).Range("a1:a2")
            r(2).Formula = "=or(row(a2)={" & Join(Filter(Sheets("error rows") _
            .[transpose(if(isnumber(a2:a1000),a2:a1000))], False, 0), ",") & "})"
            .AdvancedFilter 1, r
            r(2) = ""
        End With
    End Sub

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Auto Filter by Row Number

    @ Ochimus...I assumed OP made a mistake...

    @fireguy7...
    Thanks for rep +
    Last edited by Sintek; 12-15-2020 at 02:02 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 06-08-2018, 01:54 PM
  2. [SOLVED] count number and blanks and auto filter
    By gondal in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 08-05-2016, 06:52 AM
  3. Auto Filter and copy the specified number of rows into another sheet.
    By kittu55 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-09-2015, 11:01 AM
  4. Auto Filter - Number of records
    By Walldorc in forum Excel General
    Replies: 2
    Last Post: 12-17-2008, 09:06 AM
  5. Sort, Filter and then auto number sequentially
    By tony0710 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2008, 02:20 PM
  6. Applying auto-filter with large number of rows
    By Hari in forum Excel General
    Replies: 3
    Last Post: 01-29-2006, 11:10 PM
  7. Replies: 3
    Last Post: 08-30-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1