Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel 2007 autofilter change to 2003 autofilter functionality? | Excel Discussion (Misc queries) | |||
2007 excel autofilter back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
2007 excel autofilter change back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
Index with mulitple value returns and muliple column returns | Excel Worksheet Functions | |||
Date returns always returns: 00 January 1900 | Excel Worksheet Functions |