Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Advice Sought | Excel Programming | |||
Advice Sought | Excel Programming | |||
Proper function fix sought | Excel Discussion (Misc queries) | |||
VBA help sought | Excel Programming |