PC Review


Reply
Thread Tools Rate Thread

Application.match - apparent error?

 
 
katem
Guest
Posts: n/a
 
      19th Jun 2007
OK, this is a strange one. I'm trying to use application.match to
find a value in an array and it's giving me weird results. I'm
reading in a date as the lookup value (7/06/2007 0:13) and it's
looking through an array full of dates (sorted in ascending order) to
find the nearest lowest value:-

matchArray() =
Worksheets("Adamstown").Range("a2:a1027").Value

startArray = WorksheetFunction.Match(controlArray(i, 2),
matchArray, -1)

however, no matter what the lookup value is (in controlArray(i,2))
startArray always seems to be 440 (which isn't the right answer (440
is a date of 9/06/2007 23:56 - this is the last record for the day).
The correct answer is 2. I've input

(the dates range from 7/06/2007 0:03 to 13/06/2007 23:53) (Australian
Date System)

Can anyone help me understand why this doesn't work & how I can fix
it. I've got around it by using the match function on the worksheet
(which is giving me the correct answer) and reading this number into
startArray. However, this is an ugly solution and I'd prefer if it
didn't have to run this way.

I've tested it with different values, below and above the 9/06/2007
23:56 and the answer is always 440. If the search value is outside
the lookup range, I'm still getting 440.

i've also tried both the worksheet.match and application.match
functions, both give the same result.

If someone can give me a pointer, I can upload the file somewhere it
can be looked at, if this helps.

Thanks for your help!
Kate

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      19th Jun 2007
make sure controlArray(i,2) is a date value. You may need to add

datevalue(controlArray(i,2))

"katem" wrote:

> OK, this is a strange one. I'm trying to use application.match to
> find a value in an array and it's giving me weird results. I'm
> reading in a date as the lookup value (7/06/2007 0:13) and it's
> looking through an array full of dates (sorted in ascending order) to
> find the nearest lowest value:-
>
> matchArray() =
> Worksheets("Adamstown").Range("a2:a1027").Value
>
> startArray = WorksheetFunction.Match(controlArray(i, 2),
> matchArray, -1)
>
> however, no matter what the lookup value is (in controlArray(i,2))
> startArray always seems to be 440 (which isn't the right answer (440
> is a date of 9/06/2007 23:56 - this is the last record for the day).
> The correct answer is 2. I've input
>
> (the dates range from 7/06/2007 0:03 to 13/06/2007 23:53) (Australian
> Date System)
>
> Can anyone help me understand why this doesn't work & how I can fix
> it. I've got around it by using the match function on the worksheet
> (which is giving me the correct answer) and reading this number into
> startArray. However, this is an ugly solution and I'd prefer if it
> didn't have to run this way.
>
> I've tested it with different values, below and above the 9/06/2007
> 23:56 and the answer is always 440. If the search value is outside
> the lookup range, I'm still getting 440.
>
> i've also tried both the worksheet.match and application.match
> functions, both give the same result.
>
> If someone can give me a pointer, I can upload the file somewhere it
> can be looked at, if this helps.
>
> Thanks for your help!
> Kate
>
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      19th Jun 2007
Kate,

A "-1" match type requires the data to be sorted in descending order.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"katem" <(E-Mail Removed)>
wrote in message
OK, this is a strange one. I'm trying to use application.match to
find a value in an array and it's giving me weird results. I'm
reading in a date as the lookup value (7/06/2007 0:13) and it's
looking through an array full of dates (sorted in ascending order) to
find the nearest lowest value:-

matchArray() = Worksheets("Adamstown").Range("a2:a1027").Value
startArray = WorksheetFunction.Match(controlArray(i, 2), matchArray, -1)
-snip-
Thanks for your help!
Kate

 
Reply With Quote
 
katem
Guest
Posts: n/a
 
      20th Jun 2007
The plot thickens....

I put in a value which was in the list to match (so an exact match
would work) and it brings back 0 for every value I've tried in the
list (whether on not it's in the list). And if I run a +1 match, I
always get 1026 (which is the upperbound of the array).

I've tried it with and without the 'datevalue'.

Any other guesses as to what's up?
Thanks for your help,
Kate


On Jun 19, 10:41 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
> Kate,
>
> A "-1" match type requires the data to be sorted in descending order.
> --
> Jim Cone
> San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
>
> "katem" <kate.maun...@gmail.com>
> wrote in message
> OK, this is a strange one. I'm trying to use application.match to
> find a value in an array and it's giving me weird results. I'm
> reading in a date as the lookup value (7/06/2007 0:13) and it's
> looking through an array full of dates (sorted in ascending order) to
> find the nearest lowest value:-
>
> matchArray() = Worksheets("Adamstown").Range("a2:a1027").Value
> startArray = WorksheetFunction.Match(controlArray(i, 2), matchArray, -1)
> -snip-
> Thanks for your help!
> Kate



 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      20th Jun 2007

I don't understand your answer as you don't reference the data sort order.

If match type is -1 the data must be in descending order.
If match type is +1 the data must be in ascending order
If match type is 0 (exact match) the data can be in any order.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"katem" <(E-Mail Removed)>
wrote in message
The plot thickens....

I put in a value which was in the list to match (so an exact match
would work) and it brings back 0 for every value I've tried in the
list (whether on not it's in the list). And if I run a +1 match, I
always get 1026 (which is the upperbound of the array).

I've tried it with and without the 'datevalue'.
Any other guesses as to what's up?
Thanks for your help,
Kate


 
Reply With Quote
 
katem
Guest
Posts: n/a
 
      20th Jun 2007
Sorry - that was in my first post, should've made myself more clear.
The list is dates in ascending order, so I think +1 or 0 should work.
But neither of them are behaving.

Any guesses?
Thanks for your help!
Kate

On Jun 20, 12:56 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
> I don't understand your answer as you don't reference the data sort order.
>
> If match type is -1 the data must be in descending order.
> If match type is +1 the data must be in ascending order
> If match type is 0 (exact match) the data can be in any order.
> --
> Jim Cone
> San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
>
> "katem" <kate.maun...@gmail.com>
> wrote in message
> The plot thickens....
>
> I put in a value which was in the list to match (so an exact match
> would work) and it brings back 0 for every value I've tried in the
> list (whether on not it's in the list). And if I run a +1 match, I
> always get 1026 (which is the upperbound of the array).
>
> I've tried it with and without the 'datevalue'.
> Any other guesses as to what's up?
> Thanks for your help,
> Kate



 
Reply With Quote
 
Niek Otten
Guest
Posts: n/a
 
      20th Jun 2007
I suspect one of your dates (either the one to be looked up or in the table) is text and te other one(s) isn't.
You can easily test that with the ISTEXT function..
Just re-formatting as number or date doesn't help' you have re-format AND to re- enter (F2, ENTER) or multiply by 1 to get nembers
(dates).

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"katem" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
| Sorry - that was in my first post, should've made myself more clear.
| The list is dates in ascending order, so I think +1 or 0 should work.
| But neither of them are behaving.
|
| Any guesses?
| Thanks for your help!
| Kate
|
| On Jun 20, 12:56 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
| > I don't understand your answer as you don't reference the data sort order.
| >
| > If match type is -1 the data must be in descending order.
| > If match type is +1 the data must be in ascending order
| > If match type is 0 (exact match) the data can be in any order.
| > --
| > Jim Cone
| > San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
| >
| > "katem" <kate.maun...@gmail.com>
| > wrote in message
| > The plot thickens....
| >
| > I put in a value which was in the list to match (so an exact match
| > would work) and it brings back 0 for every value I've tried in the
| > list (whether on not it's in the list). And if I run a +1 match, I
| > always get 1026 (which is the upperbound of the array).
| >
| > I've tried it with and without the 'datevalue'.
| > Any other guesses as to what's up?
| > Thanks for your help,
| > Kate
|
|


 
Reply With Quote
 
katem
Guest
Posts: n/a
 
      20th Jun 2007
Hey - just checked and both the match array and number being read in
both are numbers. When they are in the VBA watch window, the dates
have a # on either side and the istext function reads 'false' for
both, so I don't think that's what's causing the issue. If you can
tell me where I can upload, I can send the file to somewhere for
people to look at it.

I also tried it on another computer this morning and am getting the
same results.

Thanks so much for your help - any other ideas?
Cheers,
Kate

On Jun 20, 4:16 pm, "Niek Otten" <nicol...@xs4all.nl> wrote:
> I suspect one of your dates (either the one to be looked up or in the table) is text and te other one(s) isn't.
> You can easily test that with the ISTEXT function..
> Just re-formatting as number or date doesn't help' you have re-format AND to re- enter (F2, ENTER) or multiply by 1 to get nembers
> (dates).
>
> --
> Kind regards,
>
> Niek Otten
> Microsoft MVP - Excel
>
> "katem" <kate.maun...@gmail.com> wrote in messagenews:(E-Mail Removed)...
>
> | Sorry - that was in my first post, should've made myself more clear.
> | The list is dates in ascending order, so I think +1 or 0 should work.
> | But neither of them are behaving.
> |
> | Any guesses?
> | Thanks for your help!
> | Kate
> |
> | On Jun 20, 12:56 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
> | > I don't understand your answer as you don't reference the data sort order.
> | >
> | > If match type is -1 the data must be in descending order.
> | > If match type is +1 the data must be in ascending order
> | > If match type is 0 (exact match) the data can be in any order.
> | > --
> | > Jim Cone
> | > San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
> | >
> | > "katem" <kate.maun...@gmail.com>| > wrote in message
>
> | > The plot thickens....
> | >
> | > I put in a value which was in the list to match (so an exact match
> | > would work) and it brings back 0 for every value I've tried in the
> | > list (whether on not it's in the list). And if I run a +1 match, I
> | > always get 1026 (which is the upperbound of the array).
> | >
> | > I've tried it with and without the 'datevalue'.
> | > Any other guesses as to what's up?
> | > Thanks for your help,
> | > Kate
> |
> |



 
Reply With Quote
 
Niek Otten
Guest
Posts: n/a
 
      21st Jun 2007
You can send me the file

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"katem" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
| Hey - just checked and both the match array and number being read in
| both are numbers. When they are in the VBA watch window, the dates
| have a # on either side and the istext function reads 'false' for
| both, so I don't think that's what's causing the issue. If you can
| tell me where I can upload, I can send the file to somewhere for
| people to look at it.
|
| I also tried it on another computer this morning and am getting the
| same results.
|
| Thanks so much for your help - any other ideas?
| Cheers,
| Kate
|
| On Jun 20, 4:16 pm, "Niek Otten" <nicol...@xs4all.nl> wrote:
| > I suspect one of your dates (either the one to be looked up or in the table) is text and te other one(s) isn't.
| > You can easily test that with the ISTEXT function..
| > Just re-formatting as number or date doesn't help' you have re-format AND to re- enter (F2, ENTER) or multiply by 1 to get
nembers
| > (dates).
| >
| > --
| > Kind regards,
| >
| > Niek Otten
| > Microsoft MVP - Excel
| >
| > "katem" <kate.maun...@gmail.com> wrote in messagenews:(E-Mail Removed)...
| >
| > | Sorry - that was in my first post, should've made myself more clear.
| > | The list is dates in ascending order, so I think +1 or 0 should work.
| > | But neither of them are behaving.
| > |
| > | Any guesses?
| > | Thanks for your help!
| > | Kate
| > |
| > | On Jun 20, 12:56 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
| > | > I don't understand your answer as you don't reference the data sort order.
| > | >
| > | > If match type is -1 the data must be in descending order.
| > | > If match type is +1 the data must be in ascending order
| > | > If match type is 0 (exact match) the data can be in any order.
| > | > --
| > | > Jim Cone
| > | > San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
| > | >
| > | > "katem" <kate.maun...@gmail.com>| > wrote in message
| >
| > | > The plot thickens....
| > | >
| > | > I put in a value which was in the list to match (so an exact match
| > | > would work) and it brings back 0 for every value I've tried in the
| > | > list (whether on not it's in the list). And if I run a +1 match, I
| > | > always get 1026 (which is the upperbound of the array).
| > | >
| > | > I've tried it with and without the 'datevalue'.
| > | > Any other guesses as to what's up?
| > | > Thanks for your help,
| > | > Kate
| > |
| > |
|
|


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
#NAME? error for no apparent reason... Monomeeth Microsoft Excel Worksheet Functions 2 15th Sep 2008 02:45 AM
Apparent error with WPA-PSK =?Utf-8?B?QWxsZW5idWlsZF9Kb24=?= Windows XP Networking 1 22nd Feb 2007 02:42 PM
Apparent error - help... =?Utf-8?B?RGVyZWsgRC4uLg==?= Microsoft Excel Crashes 1 9th Sep 2005 02:06 PM
Application.Match Type mismatch error marston.gould@alaskaair.com Microsoft Excel Programming 8 10th Dec 2004 09:58 AM
error 1919 ? apparent registry problem carl goodin Microsoft Windows 2000 Registry Archive 0 4th Nov 2003 08:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 PM.