Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Top 25 in a filtered list

I'm sure this has been answered before but I can't seem to
find it in the archives.

I'm looking to copy the top 25 visible rows on a filtered list.

Actually, to be specific......
Header row is 5
With the list filtered, I'm looking to copy only the first 25 visible
rows from Columns "C" through "H"

Thanks,
John


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Top 25 in a filtered list

Found it.

Thanks Bernie

"John Wilson" wrote in message
...
I'm sure this has been answered before but I can't seem to
find it in the archives.

I'm looking to copy the top 25 visible rows on a filtered list.

Actually, to be specific......
Header row is 5
With the list filtered, I'm looking to copy only the first 25 visible
rows from Columns "C" through "H"

Thanks,
John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Top 25 in a filtered list

Assuming that you are not showing the top 25 - there are probably more than
25 rows visible then:

dim rng as Range, cell as Range
Dim rng1 as Range, rng2 as Range
set rng = ActiveSheet.AutoFilter.Range
set rng = rng.offset(1,0).Resize(rng.rows.count-1).Columns(1)
for each cell in rng
if cell.entirerow.Hidden = False then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng,cell)
end if
end if
if rng1.count = 25 then exit for
Next
if not rng1 is nothing then
set rng2 = Intersect(rng1.EntireRow,Columns("C:H")
rng2.copy Destination:=Worksheets("Data1").Range("A2")
End if


--
Regards,
Tom Ogilvy


"John Wilson" wrote in message
...
I'm sure this has been answered before but I can't seem to
find it in the archives.

I'm looking to copy the top 25 visible rows on a filtered list.

Actually, to be specific......
Header row is 5
With the list filtered, I'm looking to copy only the first 25 visible
rows from Columns "C" through "H"

Thanks,
John




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Top 25 in a filtered list

Tom,

That worked too.

Thank you

What I found earlier from Bernie Deitrick was the following:

Dim myR As Range
Dim iRow As Integer
iRow = 25
Set myR = Range(Cells(6, 1), Cells(Rows.Count, 1).End(xlUp))
MsgBox "Visible row " & iRow & " is actual row " & _
GetVisibleRow(myR, iRow) & "."
Range(Range("C6"), Range("H" & LastVR)).Copy
Worksheets("top25Query").Activate
Range("B31").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

Function GetVisibleRow(myRange As Range, i As Integer) As Variant
Dim j As Integer
Dim myCell As Range
Set myRange = myRange.Offset(1, 0).Resize(myRange.Rows.Count - 1, 1)
j = 0
For Each myCell In myRange.SpecialCells(xlCellTypeVisible)
j = j + 1
If j = i Then
GetVisibleRow = myCell.Row
LastVR = myCell.Row
Exit Function
End If
Next
GetVisibleRow = "Not enough visible rows to return row " & i & "."
End Function


"Tom Ogilvy" wrote in message
...
Assuming that you are not showing the top 25 - there are probably more
than
25 rows visible then:

dim rng as Range, cell as Range
Dim rng1 as Range, rng2 as Range
set rng = ActiveSheet.AutoFilter.Range
set rng = rng.offset(1,0).Resize(rng.rows.count-1).Columns(1)
for each cell in rng
if cell.entirerow.Hidden = False then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng,cell)
end if
end if
if rng1.count = 25 then exit for
Next
if not rng1 is nothing then
set rng2 = Intersect(rng1.EntireRow,Columns("C:H")
rng2.copy Destination:=Worksheets("Data1").Range("A2")
End if


--
Regards,
Tom Ogilvy


"John Wilson" wrote in message
...
I'm sure this has been answered before but I can't seem to
find it in the archives.

I'm looking to copy the top 25 visible rows on a filtered list.

Actually, to be specific......
Header row is 5
With the list filtered, I'm looking to copy only the first 25 visible
rows from Columns "C" through "H"

Thanks,
John






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
A list of what is being filtered on? Mel Excel Discussion (Misc queries) 5 August 27th 08 05:08 PM
creating a filtered list ASU Excel Discussion (Misc queries) 1 September 14th 06 10:59 AM
Counting a Filtered List kkrebs Excel Discussion (Misc queries) 6 September 22nd 05 02:57 PM
iterating over a filtered list Eric[_27_] Excel Programming 2 May 23rd 05 01:16 PM
Navigating a filtered list Hafeez Esmail Excel Programming 3 December 11th 03 08:17 PM


All times are GMT +1. The time now is 04:09 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"