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

Hi Dave,
try useing MATCH, something like this

dim varRow as variant
dim oCurrent as range
dim oPrevious as range

set oPrevious=Range(PreviousWeek).columns(1)

for each oCurrent in currentWeek.columns(1)
varRow=application.match(oCurrent,oPrevious,1)
if iserror(varRow) then varRow=-1
' do something
next oCurrent

This code does not exploit the fact that currentweek is also sorted, so
further optimisation may be possible.

hth
Charles Williams
www.DecisionModels.com


"MSNEWS" wrote in message
...
Hi all,

I am writing some code that needs to determine the row number of a cell
where the cell contents match.

I have two sorted named Ranges : currentWeek and previousWeek
The first column of each range is a persons name. I need to find the row
number in previousWeek where the persons name from currentWeek matches.
In some cases a person that exists in currentWeek may not exist in
previousWeek (in which case returning -1 would be fine)

I two loops to do this search, but in a list of upto 1500 names, the time

it
takes is very long.

any suggestions would be appreciated.
thanks
Dave




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
Search vs find vs countif Darby Excel Discussion (Misc queries) 1 May 8th 09 03:02 PM
IF with Search/Find??? TotallyConfused Excel Worksheet Functions 5 August 1st 08 10:05 AM
search or find, and extract? SusanInTexas Excel Discussion (Misc queries) 1 August 24th 07 10:20 PM
Can Search find 2 or more "/"? Wind54Surfer Excel Discussion (Misc queries) 2 February 22nd 05 04:31 PM
Search and find Rick K Excel Programming 1 August 21st 03 04:15 AM


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