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: 166
Default VB Help sought with some code


I wonder if there's a better way to do this?

I want to build an array of line numbers where a date falls within the
Dates in Cols K and M.

The Date in 'K' is always before 'M' and they're formatted as text "03
Jan 1965" etc.

At the moment I'm using a For Next Loop to look at every line
in the sheet. This seems wasteful as there are several thousand
lines and only 100 or less cases that will match. OR - does this not
matter i.e. every line would need checking anyway?

Here's what I have :-

Variable A holds the target date.
(LastRow is from Ron de Bruin's Last Function)
----
For f = 2 To LastRow
If inTheRange(.Cells(f, "K"), .Cells(f, "M"), A) Then
ReDim Preserve l(UBound(l) + 1)
l(UBound(l)) = f
End If
Next f

Function inTheRange(DateIn, DateOut, ThisDate) As Boolean
If IsDate(DateIn) = True Then
If IsDate(DateOut) = True Then
If CDate(ThisDate) = CDate(DateIn) And CDate(ThisDate) <=
CDate(DateOut) Then inTheRange = True
End If
End If
End Function
----

Thanks for any suggestions.

Cheers - Kirk




 
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
Advice Sought JAC Excel Programming 3 September 19th 08 08:12 AM
Advice Sought JAC Excel Programming 3 September 2nd 08 08:29 AM
Proper function fix sought Niniel Excel Discussion (Misc queries) 3 September 6th 07 04:46 PM
VBA help sought H.S Excel Programming 1 March 17th 05 09:06 AM


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