MATCH goes wrong
MATCH goes wrong
(OP)
Attached file shows a couple of columns of data . For obscure reasons I want the user to be able to place the data anywhere in the yellow box, as a contiguous column.
Row 7 detects the start of the data, row 8 detects the end. 8 works in one case, not in the other. Why?
Row 7 detects the start of the data, row 8 detects the end. 8 works in one case, not in the other. Why?
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: MATCH goes wrong
On the attached copy of your worksheet I have:
1. Added a helper column (=D16<>0) and done the MATCH on that. That gives the same results as yours, and returns TRUE or FALSE correctly for both columns.
2. Extended the column of numbers in Col D to cover 66 rows. The Match formula now works correctly!
So it seems that =MATCH(TRUE,D16:D167<>0,1) only works if the number of TRUE rows > 65.
I guess the easiest solution would be to use Match to find the first row with data then COUNTIF to find the last.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: MATCH goes wrong
https://stackoverflow.com/questions/2362754/excel-...
It seems that Excel's behaviour is erratic for a Match on unsorted data.
Another alternative would be:
=MATCH(1000000,D16:D167,1)+15
which will return the row of the greatest value <= 1000000.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: MATCH goes wrong
(time goes by)
OK I looked, and under Open Office I see the exact same result. I looked at the text of the xlxs file and saw no hidden values for those cells.
I tried a number of things and the more I look at it the more I wonder how this ever works. (ISBLANK, NOT(ISNUMBER)
When I think of array formulas I think of it working as "FOR EACH" array entry, but formulas that work with that should work with it one line at a time and MATCH doesn't.
=MATCH(TRUE,H16<>0,0) fails as does =MATCH(TRUE,H16<>0,1) yet {=MATCH(TRUE,H16:H167<>0,1)+15} does.
Where did this method come from?
RE: MATCH goes wrong
The problem is, using match type = 1 it assumes the data is in ascending order, and it does a binary search. It starts with a cell close to the middle of the range, and if that is past the end of the data it will continue searching down the column until it gets to the last cell where it finds the value is as close to the search value as any other cell it has checked, so it reports that cell as the match.
When the data extends past half way it will continue working down the rows until it gets to the last one with a number, and report that as the match, which is what is wanted in this case.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: MATCH goes wrong
I suppose that this behavior is why Microsoft has deprecated array formulas in favor of dynamic arrays, but I don't have access to that.
I liked array formulas when they first came out but the number of uses that depend on side-effects suggests it was a bad implementation. For example, it doesn't allow me to sort the hidden array of TRUE/FALSE values, so it's not a first-class capability. It's got some special cases where it works, but not all cases.
RE: MATCH goes wrong
So what I wanted to do was build an array reference using the two numbers, say front_wheelrate!$C$23:$C$109
name it as 'fwr' and then use INDIRECT(fwr) for various things.
But, the way Excel handles INDIRECT(fwr) is also less than robust. So I can't do what I want, but since I found the above problem it wouldn't have worked in the general case anyway.
The official solution (apparently) is to use a table.
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: MATCH goes wrong
=MATCH(MAX(D16:D167),D16:D167,0)+15
or
=COUNTA(D16:D167)+D7-1
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: MATCH goes wrong
You have DATA in column D below the last visible characters in row 76.
Try Deleting all the rows below the last row of data on the sheet and all the columns to the right of the last column of data on the sheet. I often did this as a matter of course and checked my results using Worksheet.UsedRange by returning the Last Row & Last Column on the sheet.
This has NOTHING to do with the MATCH() function!
Your formula returns 76 as the last row with data.
Skip,
for a NUance!
RE: MATCH goes wrong
Encore Doug, Encore!
RE: MATCH goes wrong
You've got phantom DATA in column D from row 138 and downward.
I modified your formula for rows below row 76...
E77: =MATCH(TRUE,D$16:D77<>0,1)+15
...and copied down in column E in order to discover in what row the data resides.
Skip,
for a NUance!
RE: MATCH goes wrong
If you enter =D16<>0 in cell E16, and copy it down to E167, it returns FALSE for all cells from row 77 to 167. Also my suggested alternatives return the right row for the last data row.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: MATCH goes wrong
Yup that seems to be a repeatable 'feature'. Now, OK it is my fault for probably abusing MATCH, and monkey see monkey do is dangerous. IDS's alternative looks good, I'll try that.
Thank you all,
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: MATCH goes wrong
Checked out your statement, "If the search column is empty for just over half the length from the bottom the formula returns the row number for the last row in the search range rather than the last row with data."
And you're correct! I cede to your brilliance regarding a MATCH() search under these conditions.
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: MATCH goes wrong
If Greg should end up going with tables to get the information he needs, I'll leave the advice on that to you :)
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: MATCH goes wrong
Anyhow good catch.
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: MATCH goes wrong
and it works
the mystery deepens!
RE: MATCH goes wrong
But I have realised that there are approximately 2460 alternative ways of doing the same job automagically. So it is now a non problem.
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: MATCH goes wrong