Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default .Find method on filtered range

Hi All,

I focus the next problem. Somewhere in code I return a filtered range in a function

Public Function GetHistoricalSalesForAccount(accountId As String) As Range
In this function there is an autofilter applied on some of the columns in the sheet:
Set filteredRange = historicalSheet.AutoFilter.Range.Offset(1, 0).Resize(historicalSheet.AutoFilter.Range.Rows.Co unt - 1, 1).SpecialCells(xlCellTypeVisible)
So I return the filteredRange in the function.

Now in my calling sub I have the following code:
Set historicalSales = GetHistoricalSalesForAccount", accountID)
Now the trick, I need to find a specific SKU in this 'filtered' list
Dim SKUHistoricalSalesSearchResult As Range
Set SKUHistoricalSalesSearchResult = historicalSales.Cells.Find(What:=sku, LookIn:=xlValues, LookAt:=xlWhole) 'Find SKU in historical sales

Now everytime the result is NOTHING although the sku is in the filtered list.

anybody any idea?

Regards
Kurt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default .Find method on filtered range

Simplifiy your code to make it easier to isolate the problem and make the
code easier to understand

with historicalSheet
Set LastRow = .Range("A" & Rows.Count).end(xlup).Row
Set filteredRange = .Range("A2:A" & LastRow)
filteredRange.Autofilter
set AccountIDs = FilterRange.offset(0,1)
Set SKUHistoricalSalesSearchResult = AccountIDs.Cells.Find(What:=sku, _
LookIn:=xlValues, _
LookAt:=xlWhole)
end with

"Kurt Biesemans" wrote:

Hi All,

I focus the next problem. Somewhere in code I return a filtered range in a function

Public Function GetHistoricalSalesForAccount(accountId As String) As Range
In this function there is an autofilter applied on some of the columns in the sheet:
Set filteredRange = historicalSheet.AutoFilter.Range.Offset(1, 0).Resize(historicalSheet.AutoFilter.Range.Rows.Co unt - 1, 1).SpecialCells(xlCellTypeVisible)
So I return the filteredRange in the function.

Now in my calling sub I have the following code:
Set historicalSales = GetHistoricalSalesForAccount", accountID)
Now the trick, I need to find a specific SKU in this 'filtered' list
Dim SKUHistoricalSalesSearchResult As Range
Set SKUHistoricalSalesSearchResult = historicalSales.Cells.Find(What:=sku, LookIn:=xlValues, LookAt:=xlWhole) 'Find SKU in historical sales

Now everytime the result is NOTHING although the sku is in the filtered list.

anybody any idea?

Regards
Kurt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default .Find method on filtered range

Joel,

Thank you to rewrite my code to simplify the problem.

Kurt


"Joel" wrote in message
...
Simplifiy your code to make it easier to isolate the problem and make the
code easier to understand

with historicalSheet
Set LastRow = .Range("A" & Rows.Count).end(xlup).Row
Set filteredRange = .Range("A2:A" & LastRow)
filteredRange.Autofilter
set AccountIDs = FilterRange.offset(0,1)
Set SKUHistoricalSalesSearchResult = AccountIDs.Cells.Find(What:=sku, _
LookIn:=xlValues, _
LookAt:=xlWhole)
end with

"Kurt Biesemans" wrote:

Hi All,

I focus the next problem. Somewhere in code I return a filtered range in
a function

Public Function GetHistoricalSalesForAccount(accountId As String) As
Range
In this function there is an autofilter applied on some of the columns in
the sheet:
Set filteredRange = historicalSheet.AutoFilter.Range.Offset(1,
0).Resize(historicalSheet.AutoFilter.Range.Rows.Co unt - 1,
1).SpecialCells(xlCellTypeVisible)
So I return the filteredRange in the function.

Now in my calling sub I have the following code:
Set historicalSales = GetHistoricalSalesForAccount", accountID)
Now the trick, I need to find a specific SKU in this 'filtered' list
Dim SKUHistoricalSalesSearchResult As Range
Set SKUHistoricalSalesSearchResult =
historicalSales.Cells.Find(What:=sku, LookIn:=xlValues, LookAt:=xlWhole)
'Find SKU in historical sales

Now everytime the result is NOTHING although the sku is in the filtered
list.

anybody any idea?

Regards
Kurt



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
Find Method for finding the next value in a range GT certain value MichaelDavid Excel Programming 3 August 5th 09 02:40 PM
Set range with Find method jlclyde Excel Discussion (Misc queries) 1 December 3rd 08 05:44 PM
Using PivotSelect method to find the top of a range Geoff Excel Programming 0 July 12th 07 02:32 AM
Find method fails in hidden range Rick Hansen Excel Programming 2 April 6th 06 10:54 PM
Cells.Find in Auto-Filtered range mark Excel Programming 2 September 16th 03 11:55 PM


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