×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MATCH goes wrong

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?

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

Very strange, I think you have found a bug!

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

If Doug sees a bug that worries me. Should I even peek at the sheet?

(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

3DDave, if you add a helper column with H16<>0, which returns TRUE or FALSE for each row, and do the MATCH on that column, it works exactly the same as Greg's formula.

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

The question I had was how MATCH works as an array function at all, but I guess it internally generates a hidden array that is what is evaluated by the MATCH function rather than expanding that hidden array into a column of it's own values on the sheet. Even then, why isn't that array indexed from row 1 or from the row the function is on?

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

(OP)
Um, good, looks like its above my paygrade. Thank you both. Yes I had fiddled with arrays, but they didn't seem to help. As to what the MATCH(TRUE is doing, um, I stole it off the internet!

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

Greg - but there are simple formulas that do work. For instance:

=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

Greg,

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: MATCH goes wrong

Scattered applause soon increases to a full standing ovation!

Encore Doug, Encore!

RE: MATCH goes wrong

Greg,

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: MATCH goes wrong

Skip - it is nothing to do with phantom data. 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.

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

(OP)
"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."

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

Doug,

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: MATCH goes wrong

Thanks Skip.

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

I was going to ask him why the search range was not the range of the data. I suppose that there may be instances where a range of data would logically reside outside of a tabular data set. I was late to the party.

Anyhow good catch.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: MATCH goes wrong

Copy H8, Paste D8

and it works

the mystery deepens!

RE: MATCH goes wrong

(OP)
Skip - Ok, so basically I cut and paste a pair of columns that I want to analyse and also plot as XY data, and interpolate some particular points off that curve. So I can display my interpolated points fine, but for prettiness sake I also wanted to put the original curve in. But the original curve is much bigger than the small group of interpolated points, so I wanted to truncate the original pair of columns (manually) so that the displayed data is neater, without having to muck about with axis limits.


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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close