Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default MATCH FUNCTION AND SERIAL DATE CONFLICTS

I am using the Match Function to locate a user-entered date in an array
range that includes numbers, text and dates. This has worked fine for
3 years but I have today encountered a problem where Match erroneously
locates a number in the array that is the same value as the serial date
number of the date that is being searched for i.e. Date being searched
for 3/11/06 (d/mm/yy) but matches number 39024 (the serial date for 3rd
November 2006). The chances of this happening again are rare, but I
would like to eliminate the possibility.

Does anyone know of a way of forcing Excel to only match with dates,
rather than the serial date equivalent? I've tried changing formats of
various cells in the spreadsheets but Excel always seems to read the
date (behind the scenes) as the serial date number.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 380
Default MATCH FUNCTION AND SERIAL DATE CONFLICTS

I can't see that this is avoidable because Excel does not have a date type,
it is just a serial number with a specific format. So a cell with 03/11/06
and another with 39024 have the same value as you know.

You could write your own UDF and test the format, assuming you know the
format, like this

Function SpecialMatch(lookup_val, lookup_range As Range)
Const DATE_FORMAT As String = "dd-mmm-yyyy" '<== change to suit
Dim rng As Range
Dim cPrev As Long
Dim tmp

Set rng = lookup_range
cPrev = 0
Do
tmp = 0
On Error Resume Next
tmp = Application.Match(lookup_val, rng, 0)
On Error GoTo 0
If tmp = 0 Then
SpecialMatch = CVErr(xlErrNA)
Exit Do
ElseIf rng.Cells(tmp, 1).NumberFormat = DATE_FORMAT Then
SpecialMatch = tmp + cPrev
Exit Do
Else
Set rng = rng.Offset(tmp, 0).Resize(rng.Rows.Count - tmp, 1)
cPrev = cPrev + tmp
End If
Loop Until tmp = 0

End Function

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Jones the Scouse" wrote in message
oups.com...
I am using the Match Function to locate a user-entered date in an array
range that includes numbers, text and dates. This has worked fine for
3 years but I have today encountered a problem where Match erroneously
locates a number in the array that is the same value as the serial date
number of the date that is being searched for i.e. Date being searched
for 3/11/06 (d/mm/yy) but matches number 39024 (the serial date for 3rd
November 2006). The chances of this happening again are rare, but I
would like to eliminate the possibility.

Does anyone know of a way of forcing Excel to only match with dates,
rather than the serial date equivalent? I've tried changing formats of
various cells in the spreadsheets but Excel always seems to read the
date (behind the scenes) as the serial date number.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default MATCH FUNCTION AND SERIAL DATE CONFLICTS

Thanks for the information - I will try it out sometime, but it's a bit
complicated for my little brain.

I've worked out a way to get over the problem by creating a separate
and hidden look-up table that gets the dates only from the original
array table and I then use Match on the "date array".

Thanks again.
J-t-S
Bob Phillips wrote:
I can't see that this is avoidable because Excel does not have a date type,
it is just a serial number with a specific format. So a cell with 03/11/06
and another with 39024 have the same value as you know.

You could write your own UDF and test the format, assuming you know the
format, like this

Function SpecialMatch(lookup_val, lookup_range As Range)
Const DATE_FORMAT As String = "dd-mmm-yyyy" '<== change to suit
Dim rng As Range
Dim cPrev As Long
Dim tmp

Set rng = lookup_range
cPrev = 0
Do
tmp = 0
On Error Resume Next
tmp = Application.Match(lookup_val, rng, 0)
On Error GoTo 0
If tmp = 0 Then
SpecialMatch = CVErr(xlErrNA)
Exit Do
ElseIf rng.Cells(tmp, 1).NumberFormat = DATE_FORMAT Then
SpecialMatch = tmp + cPrev
Exit Do
Else
Set rng = rng.Offset(tmp, 0).Resize(rng.Rows.Count - tmp, 1)
cPrev = cPrev + tmp
End If
Loop Until tmp = 0

End Function

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Jones the Scouse" wrote in message
oups.com...
I am using the Match Function to locate a user-entered date in an array
range that includes numbers, text and dates. This has worked fine for
3 years but I have today encountered a problem where Match erroneously
locates a number in the array that is the same value as the serial date
number of the date that is being searched for i.e. Date being searched
for 3/11/06 (d/mm/yy) but matches number 39024 (the serial date for 3rd
November 2006). The chances of this happening again are rare, but I
would like to eliminate the possibility.

Does anyone know of a way of forcing Excel to only match with dates,
rather than the serial date equivalent? I've tried changing formats of
various cells in the spreadsheets but Excel always seems to read the
date (behind the scenes) as the serial date number.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,688
Default MATCH FUNCTION AND SERIAL DATE CONFLICTS

The only thing I can think of is to use a helper column that returns the
format of the lookup_array and then base the MATCH on both the format and
the value of the lookup_array:

.............A.............B
1......39024...........
2........text..............
3......3/11/06..........

This formula entered in B1 and copied down:

=CELL("format",A1)

This formula will return a code for the format of the cells in column A. See
Help for all the different codes. Based on the sample above:

G
G
D4

G = GENERAL
D4 = one of the DATE codes

Then you can base your MATCH formula on both the look_value and the format
code.

Biff

"Jones the Scouse" wrote in message
oups.com...
I am using the Match Function to locate a user-entered date in an array
range that includes numbers, text and dates. This has worked fine for
3 years but I have today encountered a problem where Match erroneously
locates a number in the array that is the same value as the serial date
number of the date that is being searched for i.e. Date being searched
for 3/11/06 (d/mm/yy) but matches number 39024 (the serial date for 3rd
November 2006). The chances of this happening again are rare, but I
would like to eliminate the possibility.

Does anyone know of a way of forcing Excel to only match with dates,
rather than the serial date equivalent? I've tried changing formats of
various cells in the spreadsheets but Excel always seems to read the
date (behind the scenes) as the serial date number.



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 340
Default MATCH FUNCTION AND SERIAL DATE CONFLICTS

You could make a text copy of the lookup column and use this for the
lookup. If it's a long column you could try this: Insert a column and
format as text, copy the lookup column to the clipboard (by pressing
ctrl+C twice) then paste to the new column using the clipboard icon.


Jones the Scouse wrote:

I am using the Match Function to locate a user-entered date in an array
range that includes numbers, text and dates. This has worked fine for
3 years but I have today encountered a problem where Match erroneously
locates a number in the array that is the same value as the serial date
number of the date that is being searched for i.e. Date being searched
for 3/11/06 (d/mm/yy) but matches number 39024 (the serial date for 3rd
November 2006). The chances of this happening again are rare, but I
would like to eliminate the possibility.

Does anyone know of a way of forcing Excel to only match with dates,
rather than the serial date equivalent? I've tried changing formats of
various cells in the spreadsheets but Excel always seems to read the
date (behind the scenes) as the serial date number.




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
date function [email protected] Excel Discussion (Misc queries) 3 March 22nd 06 12:16 PM
date function [email protected] Excel Discussion (Misc queries) 0 March 21st 06 11:37 PM
Match function David Excel Worksheet Functions 6 December 13th 05 07:06 AM
Where is DateDiff function in Excel 2002 ? Nigel Welch Excel Worksheet Functions 4 March 4th 05 03:18 PM
Use Julian Date To Create Serial Number antho10359 Excel Discussion (Misc queries) 4 December 9th 04 01:50 AM


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