Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autofilter returns

Hi,

I have an autofilter being set up in VBA and wish to get
the row numbers of the values that are returned once the
criteria are selected.

Can anyone advise on how to do this?

Regards,

Nathan.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Autofilter returns

Why? There may be an easier way to do what you want such as copy visible
cells only.
Have a look in vba HELP for SPECIALCELLS.

"Nath" wrote in message
...
Hi,

I have an autofilter being set up in VBA and wish to get
the row numbers of the values that are returned once the
criteria are selected.

Can anyone advise on how to do this?

Regards,

Nathan.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Autofilter returns

You can use SpecialCells(xlVisible) to work with the filtered rows:

Sub GetRows()
Dim rng As Range
Dim rng2 As Range
Dim c As Range

If Not ActiveSheet.AutoFilterMode Then
MsgBox "AutoFilter not active"
Exit Sub
End If

Set rng = ActiveSheet.AutoFilter.Range
Set rng2 = rng.Columns(1).SpecialCells(xlVisible)

If rng2.Count - 1 = 0 Then
MsgBox "No records found"
Else
For Each c In rng2
Debug.Print c.Row
Next c
End If

End Sub


Nath wrote:
I have an autofilter being set up in VBA and wish to get
the row numbers of the values that are returned once the
criteria are selected.


--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Autofilter returns

Dim rng as Range
Dim rng1 as Range
Dim icnt as Long
Dim sStr as String
set rng = Activesheet.Autofilter.Range.columns(1).Cells
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
On Error Resume Next
set rng1 = rng.SpecialCells(xlVisible)
On Error goto 0
sStr = ""
if not rng1 is nothing then
icnt = 0
for each cell in rng1
icnt = icnt + 1
sStr = cell.Row & iif(icnt mode 10,", ",vbNewline)
Next
msgbox sStr
Else
msgbox "No visible rows"
End if

--
Regards,
Tom Ogilvy


"Nath" wrote in message
...
Hi,

I have an autofilter being set up in VBA and wish to get
the row numbers of the values that are returned once the
criteria are selected.

Can anyone advise on how to do this?

Regards,

Nathan.



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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
Index with mulitple value returns and muliple column returns solar+CSE Excel Worksheet Functions 4 June 12th 09 04:43 PM
Date returns always returns: 00 January 1900 ArcticWolf Excel Worksheet Functions 2 September 11th 08 12:31 PM


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