ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Speed - or lack of it (https://www.excelbanter.com/excel-programming/306874-speed-lack.html)

don bowyer

Speed - or lack of it
 
I have a range of 5 columns 2000 rows long.
I need to look up one specific date in the 1st column.
Is it faster to use ".Find" or " For Each...Next".
I will not ".Select" the found item.
Any advice much appreciated.
Don

Tushar Mehta

Speed - or lack of it
 
While I suspect the Find method will be faster, it might be easiest if
you checked the performance of the two options yourself.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have a range of 5 columns 2000 rows long.
I need to look up one specific date in the 1st column.
Is it faster to use ".Find" or " For Each...Next".
I will not ".Select" the found item.
Any advice much appreciated.
Don


Tom Ogilvy

Speed - or lack of it
 
Find would be faster, but it often has trouble with finding dates. I would
use application.Match

Dim res as Variant, rng as Range, myDate as Date
With Worksheets("Data")
set rng = .Range(.Cells(1,1),.Cells(rows.count,1).End(xlup))
End With
myDate = #12/23/2004#
res = Application.Match(clng(myDate),rng,0)
if not iserror(res) then
msgbox "Found in cell " & rng(res).Address
Else
msgbox "Not found"
End if

--
Regards,
Tom Ogilvy


"Don Bowyer" wrote in message
...
I have a range of 5 columns 2000 rows long.
I need to look up one specific date in the 1st column.
Is it faster to use ".Find" or " For Each...Next".
I will not ".Select" the found item.
Any advice much appreciated.
Don





All times are GMT +1. The time now is 10:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com