LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Getting row numbers of a filtered dataset

Hello VBA guru,
I am new in VBA in Excel, and I was looking for a way to get row
numbers of a filtered dataset. I mean, I have 1000 rows in my original
dataset I filter them and I would like to get which rows are in the
filtered dataset.
I made a search in the ng but didn't find the solution. Since I manage
to hack it, I would like to share it. Pls don't blame if the code is
not optimized (as well as my english!), as I said I am newbe about it.

MassimoM

Public DefCriteriaRange As Variant
Public filteredRows As New Collection
-------------------------------------------

Private Sub btn_Filtra_Click()

Dim filteredRange As Range
Dim completeData As Range

Set completeDataSet = Range("A13:X882")


' Filter using criteria defined in DefCriteriaRange variable
completeDataSet.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Range(DefCriteriaRange), Unique:=False

' get the range of filtered data using visible cell criteria
Set filteredRange = completeDataSet.SpecialCells(xlVisible)

' Reset the collection
For i = 1 To filteredRows.Count
filteredRows.Remove (1)
Next i

' get addresses of filtered rows
addressesFilteredRows =
completeDataSet.SpecialCells(xlVisible).Address
' split the addresses
addressesSplitted = Split(addressesFilteredRows, ",")
' # of rows in the filtered range
nFilteredRows = completeDataSet.Columns(1).SpecialCells(xlVisible) .Count
- 1

' get rows numebers

For i = 1 To nFilteredRows
filteredRows.Add Range(addressesSplitted(i)).Row
Next i

' filteredRows contains the rows numbers as long.
 
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
Sum a Filtered List excluding Negative Numbers Chris waller Excel Discussion (Misc queries) 6 October 7th 09 03:34 PM
How do I include filtered out numbers in a SUBTOTAL? CMDMHHS Excel Worksheet Functions 5 June 24th 06 03:35 PM
counting unique numbers in filtered data deb Excel Worksheet Functions 1 September 22nd 05 09:41 PM
Counting a Filtered Dataset T De Villiers Excel Worksheet Functions 1 September 5th 05 04:28 PM
creating a new dataset brian kaufmann Excel Programming 0 August 16th 04 08:47 PM


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