LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
RPW RPW is offline
external usenet poster
 
Posts: 52
Default How do I identify range of filtered sheet?

Thanks for the helpful advice and solution. I hadn't considered the "only
headers visible' possibility.
--
rpw


"Dave Peterson" wrote:

Be careful with that firstrow line. Depending on where the visible rows are,
you may not get what you want.

Imagine that row 1 contains the headers and rows 2-99 contain the same value.
When you filter by that value, the first row will be row 2, not the first row of
the second area--heck, there may not even be a second area!

I usually use something like:

With activesheet.AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then
MsgBox "only the headers are visible"
else
'resize to avoid the header
'and come down one row
Set VisRng = .Resize(.Rows.Count - 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
End With



rpw wrote:

Cancel this question. Thank you all because I've been able to (finally) find
what I needed from other posts. Here's shortcut version in case anyone is
interested:

Dim ws1 As Worksheet
Dim LastRow As Long, FirstRow As Long

Set ws1 = Worksheets("MySheet")

ws1.Activate
With ws1
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
FirstRow = Cells.SpecialCells(xlCellTypeVisible).Areas(2).Row
End With
MsgBox FirstRow
MsgBox LastRow
--
rpw

"rpw" wrote:

Hello all,

Using Excel 2007. I have a worksheet that I filter and then copy/paste the
results to another worksheet. I have a list of filter criteria and perform a
new filter for each item in the list.

When I apply the first filter, the result is 9 rows - A3:A86. The next
filter I apply will have different results - 5 rows - A17:A345.

My 'stuck point' is programatically identifying the results range
(specifically the row numbers) after the filter is applied. Row 1 is column
headers.

I hope that this is clear enough. Any help is greatly appreciated. Thanks
in advance.
--
rpw


--

Dave Peterson

 
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
Copy Paste from Class Sheet to Filtered List on Combined Sheet [email protected] Excel Programming 6 September 16th 08 04:30 PM
Paste range of values into filtered sheet ken2005 Excel Discussion (Misc queries) 3 October 3rd 05 11:22 AM
Identify the contents of column in a filtered range Jeff Excel Worksheet Functions 6 June 26th 05 11:25 PM
traversing through a filtered range based on another filtered range zestpt[_4_] Excel Programming 4 July 12th 04 06:37 PM
Copying a Filtered Range from a Sheet in another Workbook Frederick Excel Programming 2 August 10th 03 03:29 PM


All times are GMT +1. The time now is 10:10 PM.

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"