Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default FInding a Date with wildcard

I am trying to find a date within a row of dates. The dates are actually
calculations(a series), formatted to read as dates. The other rub here is
that becasue of the calculation the day of the month is varied since the
original creator of the spreadsheet adds 32 to the previous date. (Oh by the
way the date is formatted for Canada and not the USA which means the month
and day are reversed)

So can I use * or must I use a function to convert the date calculations
beofre I do a Find

I typically use:
ColRef2 = xlApp.Rows(5).Find("1/1/2005").Column

But it is not working since the day value is not "1" but rather a number
other than "1". SO I tried the following without any success
ColRef2 = xlApp.Rows(5).Find("1/*/2005").Column

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default FInding a Date with wildcard

Try as UDF:
1. you'll need to call IsWithin with the value in each cell
2. see the comments in IsWithin
3. your wildcard is BOTH the day of the month & the month of the year
4. this is for the UK: adapt for other regional settings

Function IsWithin(ByVal mydate As Date, ByVal myyear As Integer) As Boolean
Select Case Sgn((DateValue(("01/01/" & myyear)) - mydate)) +
Sgn((DateValue(("31/12/" & myyear)) - mydate))
Case -2
IsWithin = False 'exceeds maximum
Case -1
IsWithin = True 'equals maximum
Case 0
IsWithin = True 'within minimum & maximum
Case 1
IsWithin = True 'equals minimum
Case 2
IsWithin = False ' below mimimum
End Select
End Function

Sub aa()
MsgBox IsWithin("01/03/2004", 2004)
End Sub


"Jenny" wrote:

I am trying to find a date within a row of dates. The dates are actually
calculations(a series), formatted to read as dates. The other rub here is
that becasue of the calculation the day of the month is varied since the
original creator of the spreadsheet adds 32 to the previous date. (Oh by the
way the date is formatted for Canada and not the USA which means the month
and day are reversed)

So can I use * or must I use a function to convert the date calculations
beofre I do a Find

I typically use:
ColRef2 = xlApp.Rows(5).Find("1/1/2005").Column

But it is not working since the day value is not "1" but rather a number
other than "1". SO I tried the following without any success
ColRef2 = xlApp.Rows(5).Find("1/*/2005").Column

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
Wildcard for finding items that start with ? KrispyData Excel Discussion (Misc queries) 4 August 7th 09 04:17 PM
Finding a Date 90 days previous to present date Vinod Excel Worksheet Functions 2 June 15th 09 01:18 PM
Wildcard for finding the first numeric digit in a cell? lovemuch Excel Worksheet Functions 2 August 17th 06 11:55 PM
finding a date/time in a list that is closest to an existing date/ Jamie Excel Discussion (Misc queries) 1 May 27th 06 08:54 PM
Finding the Monday date based on a different date in same week dandiehl Excel Worksheet Functions 4 April 11th 06 06:03 PM


All times are GMT +1. The time now is 01:17 PM.

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"