Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Trouble with Filtered Ranges

I am pretty new to Excel Object Model. I need some help.

I have two worksheets that have two columns in both where data has to be
matched and non-matching data have to be marked out in one of the sheets.

Following is the code that I use to do the match :
---------------------------------------------------------------------------

'STEP-1 : Find MasterID in Parent set
Set rng1 = sA.Range("A:A").Find(sB.Col1.cell(2,1), , , xlWhole)

if not rng1 is Nothing then

' STEP-2 : Filter out all rows with matching MasterID from the Parent set
sA.Range("A1:Q5000").AutoFilter( _
Field:=13, _

Criteria1:=sB.Col1.cell(2,1) , _
Visibledropdown:=False)

set rng2 = sA.autofilter.range
'set rng2 = sA.autofilter.range.specialcells(xlVisible)

' Get the number of rows filtered
intFilteredRowsCount = rng2.Columns(13).SpecialCells(xlVisible).Count-1

if not rng2 is nothing then

' STEP-3 : Find the ChildID in the filtered rows of Parent set.
Set rng3 = rng2.Range("A1:A" & intFilteredRowsCount ).Find ( _

sB.Col3.Cells(2,3), _

, _

, _
xlWhole,

xlByColumns, xlNext)
end if

end if


I expected the "rng2" to have cells/rows only that met the filter
criterion, but though the worksheet sA displays only the filtered rows, the
find function in STEP-3 is searching the entire worksheet as if there was no
filter.

My queries:
1. Why is the rng2 visibly filtered, but not accessible as filtered set?
2. Why does the value of rng2.cell(R, C) correspond to the value of cell( R,
C )
in used range of the worksheet despite the fact that rng2 represents a
range
which should hold a set of filtered rows?
3. How should I access the set of resulting data after I apply the
autofilter method on a range?

Could anyone throw some light on the above problem?

Thanks, Rajesh


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
Trouble with Pivot Tables & Named Ranges PurpleMilk Excel Worksheet Functions 0 March 4th 10 11:41 PM
Trouble identifying filtered column Eric_NY Excel Discussion (Misc queries) 1 December 1st 08 11:05 PM
Count Filtered Visible Items that Match Numeric Criteria between two ranges Sam via OfficeKB.com Excel Worksheet Functions 4 September 20th 06 06:39 PM
Trouble with selecting multiple ranges of data markag Excel Worksheet Functions 2 June 23rd 06 04:35 PM
Create my own Class Object for Ranges, having trouble assigning name property [email protected] Excel Programming 4 November 29th 05 06:08 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"