+ Reply to Thread
Results 1 to 8 of 8

how do i identify first and last row once filter applied

  1. #1
    pete the greek
    Guest

    how do i identify first and last row once filter applied

    having applied an auto filter in vba how do i indentify the first and last
    row of the result also is it possible to read the number of rows. i assume
    this is held somewhere as it is used in the status bar message

  2. #2
    Bob Phillips
    Guest

    Re: how do i identify first and last row once filter applied

    All rows would be

    rng.Rows.Count

    where rng is the original range being filtered,

    visible rows would be

    Rng.SpecialCells(xlCellTypeVisible).Count

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "pete the greek" <[email protected]> wrote in message
    news:[email protected]...
    > having applied an auto filter in vba how do i indentify the first and last
    > row of the result also is it possible to read the number of rows. i assume
    > this is held somewhere as it is used in the status bar message




  3. #3
    pete the greek
    Guest

    Re: how do i identify first and last row once filter applied

    hi bob

    sorry its taken a while to get back to you

    i am applying a filter to 3 columns and would like to know how many records
    9rows) i end up with

    would rng be the range before i apply the filters or after the second and
    before the third

    "Bob Phillips" wrote:

    > All rows would be
    >
    > rng.Rows.Count
    >
    > where rng is the original range being filtered,
    >
    > visible rows would be
    >
    > Rng.SpecialCells(xlCellTypeVisible).Count
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (replace somewhere in email address with gmail if mailing direct)
    >
    > "pete the greek" <[email protected]> wrote in message
    > news:[email protected]...
    > > having applied an auto filter in vba how do i indentify the first and last
    > > row of the result also is it possible to read the number of rows. i assume
    > > this is held somewhere as it is used in the status bar message

    >
    >
    >


  4. #4
    pete the greek
    Guest

    Re: how do i identify first and last row once filter applied

    hi bob

    have tried this and it works but "Rng.SpecialCells(xlCellTypeVisible).Count
    " counts cell my spreadsheet has 200 columns and 22500 rows

    ive tried adding ".rows" but i then get a result of 1

    i appreciate i could divide the result by the number of columns but then i
    got to deal with fractions as well

    any ideas

    "Bob Phillips" wrote:

    > All rows would be
    >
    > rng.Rows.Count
    >
    > where rng is the original range being filtered,
    >
    > visible rows would be
    >
    > Rng.SpecialCells(xlCellTypeVisible).Count
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (replace somewhere in email address with gmail if mailing direct)
    >
    > "pete the greek" <[email protected]> wrote in message
    > news:[email protected]...
    > > having applied an auto filter in vba how do i indentify the first and last
    > > row of the result also is it possible to read the number of rows. i assume
    > > this is held somewhere as it is used in the status bar message

    >
    >
    >


  5. #5
    Bernie Deitrick
    Guest

    Re: how do i identify first and last row once filter applied

    Pete,

    I'm not sure how you set rng, but for this example select just one column of the list prior to
    filtering that column...

    Sub TryNow()
    Dim Rng As Range
    Dim myAreas As Integer
    Dim myCells As Integer

    Set Rng = Selection
    myAreas = Rng.SpecialCells(xlCellTypeVisible).Areas.Count
    myCells = Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells.Count
    MsgBox "First row of data is " & _
    IIf(Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells.Count = 1, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(2).Cells(1).Row, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells(2).Row)
    MsgBox "Last row of data is " & _
    Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells(myCells).Row
    MsgBox "Total rows of data is " & Rng.SpecialCells(xlCellTypeVisible).Count - 1
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "pete the greek" <[email protected]> wrote in message
    news:[email protected]...
    > hi bob
    >
    > have tried this and it works but "Rng.SpecialCells(xlCellTypeVisible).Count
    > " counts cell my spreadsheet has 200 columns and 22500 rows
    >
    > ive tried adding ".rows" but i then get a result of 1
    >
    > i appreciate i could divide the result by the number of columns but then i
    > got to deal with fractions as well
    >
    > any ideas
    >
    > "Bob Phillips" wrote:
    >
    >> All rows would be
    >>
    >> rng.Rows.Count
    >>
    >> where rng is the original range being filtered,
    >>
    >> visible rows would be
    >>
    >> Rng.SpecialCells(xlCellTypeVisible).Count
    >>
    >> --
    >> HTH
    >>
    >> Bob Phillips
    >>
    >> (replace somewhere in email address with gmail if mailing direct)
    >>
    >> "pete the greek" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > having applied an auto filter in vba how do i indentify the first and last
    >> > row of the result also is it possible to read the number of rows. i assume
    >> > this is held somewhere as it is used in the status bar message

    >>
    >>
    >>




  6. #6
    Bernie Deitrick
    Guest

    Re: how do i identify first and last row once filter applied

    Pete,

    I'm not sure how you set rng, but for this example select just one column of the list prior to
    filtering that column...

    Sub TryNow()
    Dim Rng As Range
    Dim myAreas As Integer
    Dim myCells As Integer

    Set Rng = Selection
    myAreas = Rng.SpecialCells(xlCellTypeVisible).Areas.Count
    myCells = Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells.Count
    MsgBox "First row of data is " & _
    IIf(Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells.Count = 1, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(2).Cells(1).Row, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells(2).Row)
    MsgBox "Last row of data is " & _
    Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells(myCells).Row
    MsgBox "Total rows of data is " & Rng.SpecialCells(xlCellTypeVisible).Count - 1
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "pete the greek" <[email protected]> wrote in message
    news:[email protected]...
    > hi bob
    >
    > have tried this and it works but "Rng.SpecialCells(xlCellTypeVisible).Count
    > " counts cell my spreadsheet has 200 columns and 22500 rows
    >
    > ive tried adding ".rows" but i then get a result of 1
    >
    > i appreciate i could divide the result by the number of columns but then i
    > got to deal with fractions as well
    >
    > any ideas
    >
    > "Bob Phillips" wrote:
    >
    >> All rows would be
    >>
    >> rng.Rows.Count
    >>
    >> where rng is the original range being filtered,
    >>
    >> visible rows would be
    >>
    >> Rng.SpecialCells(xlCellTypeVisible).Count
    >>
    >> --
    >> HTH
    >>
    >> Bob Phillips
    >>
    >> (replace somewhere in email address with gmail if mailing direct)
    >>
    >> "pete the greek" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > having applied an auto filter in vba how do i indentify the first and last
    >> > row of the result also is it possible to read the number of rows. i assume
    >> > this is held somewhere as it is used in the status bar message

    >>
    >>
    >>




  7. #7
    Bernie Deitrick
    Guest

    Re: how do i identify first and last row once filter applied

    Pete,

    I'm not sure how you set rng, but for this example select just one column of the list prior to
    filtering that column...

    Sub TryNow()
    Dim Rng As Range
    Dim myAreas As Integer
    Dim myCells As Integer

    Set Rng = Selection
    myAreas = Rng.SpecialCells(xlCellTypeVisible).Areas.Count
    myCells = Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells.Count
    MsgBox "First row of data is " & _
    IIf(Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells.Count = 1, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(2).Cells(1).Row, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells(2).Row)
    MsgBox "Last row of data is " & _
    Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells(myCells).Row
    MsgBox "Total rows of data is " & Rng.SpecialCells(xlCellTypeVisible).Count - 1
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "pete the greek" <[email protected]> wrote in message
    news:[email protected]...
    > hi bob
    >
    > have tried this and it works but "Rng.SpecialCells(xlCellTypeVisible).Count
    > " counts cell my spreadsheet has 200 columns and 22500 rows
    >
    > ive tried adding ".rows" but i then get a result of 1
    >
    > i appreciate i could divide the result by the number of columns but then i
    > got to deal with fractions as well
    >
    > any ideas
    >
    > "Bob Phillips" wrote:
    >
    >> All rows would be
    >>
    >> rng.Rows.Count
    >>
    >> where rng is the original range being filtered,
    >>
    >> visible rows would be
    >>
    >> Rng.SpecialCells(xlCellTypeVisible).Count
    >>
    >> --
    >> HTH
    >>
    >> Bob Phillips
    >>
    >> (replace somewhere in email address with gmail if mailing direct)
    >>
    >> "pete the greek" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > having applied an auto filter in vba how do i indentify the first and last
    >> > row of the result also is it possible to read the number of rows. i assume
    >> > this is held somewhere as it is used in the status bar message

    >>
    >>
    >>




  8. #8
    Bernie Deitrick
    Guest

    Re: how do i identify first and last row once filter applied

    Pete,

    I'm not sure how you set rng, but for this example select just one column of the list prior to
    filtering that column...

    Sub TryNow()
    Dim Rng As Range
    Dim myAreas As Integer
    Dim myCells As Integer

    Set Rng = Selection
    myAreas = Rng.SpecialCells(xlCellTypeVisible).Areas.Count
    myCells = Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells.Count
    MsgBox "First row of data is " & _
    IIf(Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells.Count = 1, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(2).Cells(1).Row, _
    Rng.SpecialCells(xlCellTypeVisible).Areas(1).Cells(2).Row)
    MsgBox "Last row of data is " & _
    Rng.SpecialCells(xlCellTypeVisible).Areas(myAreas).Cells(myCells).Row
    MsgBox "Total rows of data is " & Rng.SpecialCells(xlCellTypeVisible).Count - 1
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "pete the greek" <[email protected]> wrote in message
    news:[email protected]...
    > hi bob
    >
    > have tried this and it works but "Rng.SpecialCells(xlCellTypeVisible).Count
    > " counts cell my spreadsheet has 200 columns and 22500 rows
    >
    > ive tried adding ".rows" but i then get a result of 1
    >
    > i appreciate i could divide the result by the number of columns but then i
    > got to deal with fractions as well
    >
    > any ideas
    >
    > "Bob Phillips" wrote:
    >
    >> All rows would be
    >>
    >> rng.Rows.Count
    >>
    >> where rng is the original range being filtered,
    >>
    >> visible rows would be
    >>
    >> Rng.SpecialCells(xlCellTypeVisible).Count
    >>
    >> --
    >> HTH
    >>
    >> Bob Phillips
    >>
    >> (replace somewhere in email address with gmail if mailing direct)
    >>
    >> "pete the greek" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > having applied an auto filter in vba how do i indentify the first and last
    >> > row of the result also is it possible to read the number of rows. i assume
    >> > this is held somewhere as it is used in the status bar message

    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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