Find lowest LEN difference & return contents of cell to left

ellison

Active Member
Joined
Aug 1, 2012
Messages
356
Office Version
  1. 365
Platform
  1. Windows
Hi, we are tidying up some data and would like to find (for each row) the Suggested-Match associated with the lowest "LEN difference".

The Suggested Matches are in Columns B, D & F (although some are blank).
The respective "LEN difference" values are in Columns C, E & G.
The lowest "LEN difference" for the row is in Column H
And we would like to return the contents of the cell which is "1 cell to the left" of the minimum LEN difference for that row (or return "_problem" if there are no Suggested Matches)

Please note that sometimes there are:
- blanks cell in the potential matches
- no potential matches at all (in which case return: "_problem")
- 2 cells which share the same lowest LEN value (in which case, return the contents of the first of the Suggested Matches)
- the LEN value can be a negative number

Hopefully this may look a bit clearer in a table!

Any help you could provide would be very much appreciated....


find-lowest-len-difference-&-return-contents-of-cell-to-right-question.xlsx
ABCDEFGHIJK
1RowSuggested-Match-AMatch-A LEN differenceSuggested-Match-BMatch-B LEN differenceSuggested-Match-CMatch-C LEN differenceLowest LEN DifferenceTARGET via formulaTARGET manuallyExplanation
22AB12 generic8AB120AB12-0430AB12Lowest LEN difference on this row is "0" in cell E2, so we would like to return the contents of cell D2
33XYZ-78911XYZ-789Match-A and Match B are blank, but the lowest LEN difference is the contents of cell F3
440_problemNo potential matches offered, so return: "_problem"
5573P_173P-1173PC2 same values are the lowest LEN difference, please return the 1st value "on the left": cell D2
6626-10-BETA-22610BETA0-226-10-BETAThe lowest LEN match is the "-2" in cell C6, so please return the contents of cell B6
Sheet1
Cell Formulas
RangeFormula
A2:A6A2=ROW()
H2:H6H2=MIN(C2,E2,G2)
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try

Book1
ABCDEFGHIJK
1RowSuggested-Match-AMatch-A LEN differenceSuggested-Match-BMatch-B LEN differenceSuggested-Match-CMatch-C LEN differenceLowest LEN DifferenceTARGET via formulaTARGET manuallyExplanation
22AB12 generic8AB120AB12-0430AB12AB12Lowest LEN difference on this row is "0" in cell E2, so we would like to return the contents of cell D2
33XYZ-78911XYZ-789XYZ-789Match-A and Match B are blank, but the lowest LEN difference is the contents of cell F3
440_problem_problemNo potential matches offered, so return: "_problem"
5573P_173P-1173P_73PC2 same values are the lowest LEN difference, please return the 1st value "on the left": cell D2
6626-10-BETA-22610BETA0-226-10-BETA26-10-BETAThe lowest LEN match is the "-2" in cell C6, so please return the contents of cell B6
7
Sheet1
Cell Formulas
RangeFormula
H2:H6H2=MIN(C2,E2,G2)
I2:I6I2=IF(INDEX(B2:H2,,MATCH(MIN(C2,E2,G2),B2:H2,0)-1)=0,"_problem",INDEX(B2:H2,,MATCH(MIN(C2,E2,G2),B2:H2,0)-1))
A2:A6A2=ROW()
 
Upvote 0
Solution
Wow that looks amazing - nearly there! I'm getting an error on Row 4.

i.e. the formula returns "#N/A" rather than "_problem"
 
Upvote 0
Can you post all the data including the data with error
 
Upvote 0
Many thanks for coming back Sufiyan, I have no idea why I was getting the error message but I have just tried it out on a few different sets of data and everything is fine.
Gremlin must have been at my end!

Solution marked up as above.

Many, many thanks!
 
Upvote 0

Forum statistics

Threads
1,224,883
Messages
6,181,550
Members
453,052
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top