Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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).C ells.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" wrote in message
...
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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying function after filter is applied lacklustre Excel Worksheet Functions 4 October 11th 09 05:07 AM
How to put series of number in excel when the filter is applied? bhanu reakha[_2_] Excel Discussion (Misc queries) 3 August 5th 09 03:13 PM
Copy only visible cells after filter is applied/ sum after filter MAM Excel Worksheet Functions 0 April 9th 08 04:09 AM
Refresh with Advance Filter Applied Carl A. Excel Discussion (Misc queries) 0 November 13th 06 08:51 PM
FILTER applied to many coloumns [email protected] Excel Discussion (Misc queries) 0 September 12th 06 09:52 AM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"