Can some explain this formula. I know what it does, I just want to understand why

Jarodjp42

New Member
Joined
Nov 21, 2017
Messages
35
=LOOKUP(10^9,--MID(J43,MIN(FIND({0,1,2,3,4,5,6,7,8,9},J43&"0123456789")),{1,2,3,4,5,6,7,8}))

Here is the formula, I am confused about the 10^9 and the -- that are listed in the formula. Can someone break it down and explain the meaning behind the inputs please?
Thank you!!!

Homes for 165.99 in town
nco financial Group Inc 77.43
Department, Inc. 113.60 ok
ncetonOne207.49San jose
d M655.72ellon hop[e
ve Boro Realty corp 97.77
ton's449.78 floats
46.27 road

<colgroup><col><col span="2"></colgroup><tbody>
</tbody>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Breaking it down using your first text string of:

Homes for 165.99 in town

The MID function needs the following MID(text,start number, num_Char)

This part of the formula
J43&"0123456789"

<colgroup><col width="255"></colgroup><tbody>
</tbody>
returns:
Homes for 165.99 in town0123456789

Then the:
FIND({0,1,2,3,4,5,6,7,8,9},J43&"0123456789")
returns the position of the numbers in the string:
{25,11,27,28,29,13,12,32,33,15}

<colgroup><col width="514"></colgroup><tbody>
</tbody>

TheMIN
MIN(FIND({0,1,2,3,4,5,6,7,8,9},J43&"0123456789")):
returns the 11 from the above array which gives the stating number for the MID function.

MID(J43,MIN(FIND({0,1,2,3,4,5,6,7,8,9},J43&"0123456789")),{1,2,3,4,5,6,7,8})
This part will return an array of the num_Char that the MID needs or:
{"1","16","165","165.","165.9","165.99","165.99 ","165.99 i"}

<colgroup><col width="656"></colgroup><tbody>
</tbody>

The double negative (--) will turn the above teat strings into values:
{1,16,165,165,165.9,165.99,165.99,#VALUE!}

<colgroup><col width="656"></colgroup><tbody>
</tbody>

The 10^9 is what is often referred to as a BIG NUMBER. It is a number that will be bigger than anything you would find in your lookup array, can be any large number (200 would have worked in this example).

Since LOOKUP will never find this BIG NUMBER it will return the biggest number in the array which in this example is 165.99.




<colgroup><col width="514"></colgroup><tbody>
</tbody>



<colgroup><col width="514"></colgroup><tbody>
</tbody>



<colgroup><col width="514"></colgroup><tbody>
</tbody>

<colgroup><col width="255"></colgroup><tbody>
</tbody>
 
Upvote 0
@AhoyNC Could you explain why the formula would need to have J43&"0123456789" in the FIND function. I understand the cell reference, but don't understand why the function needs to have &"0123456789" for it to work. I would really appreciate the help.
 
Upvote 0
Try taking out &"0123456789", you'll probably get an #N/A error. FIND function is trying to find each of the 10 digits, to ensure there is no error you can concatenate "0123456789" to the lookup cell. An alternative is to use IFERROR like this:

=LOOKUP(10^9,--MID(J43,MIN(IFERROR(FIND({0,1,2,3,4,5,6,7,8,9},J43),"")),{1,2,3,4,5,6,7,8}))
 
Upvote 0
Try taking out &"0123456789", you'll probably get an #N/A error. FIND function is trying to find each of the 10 digits, to ensure there is no error you can concatenate "0123456789" to the lookup cell. An alternative is to use IFERROR like this:

=LOOKUP(10^9,--MID(J43,MIN(IFERROR(FIND({0,1,2,3,4,5,6,7,8,9},J43),"")),{1,2,3,4,5,6,7,8}))

I would not recommend that all. At the time I designed the core formula iferror was not available (lucky me). By the way, I would never use anything like 10^9.
 
Upvote 0
I would not recommend that all. At the time I designed the core formula iferror was not available (lucky me). By the way, I would never use anything like 10^9.

Why would you never use anything like 10^9?? If using big data and copying the formula down it will allow me to never have to edit the formula because no number will be bigger than that.
Also, IFERROR function works perfectly. Your explanation helped me understand why that was in there and a work around with the IFERROR function. Thanks @BarryHoudini
 
Upvote 0
Why would you never use anything like 10^9?? If using big data and copying the formula down it will allow me to never have to edit the formula because no number will be bigger than that.

The big number I'd use is one of the Excel itself, That is:

9.99999999999999E+307

So the formula you have becomes:

=LOOKUP(9.99999999999999E+307,--MID(J43,MIN(FIND({0,1,2,3,4,5,6,7,8,9},J43&"0123456789")),{1,2,3,4,5,6,7,8}))

See: https://www.mrexcel.com/forum/excel-questions/102091-9-9999999-a.html

Also, IFERROR function works perfectly. Your explanation helped me understand why that was in there and a work around with the IFERROR function. Thanks @BarryHoudini

IFERROR is inefficient/costly. So what the original author (i.e. me) avoids the error condition at almost no cost.

https://www.mrexcel.com/forum/excel-questions/9830-separate-text-numbers-string-3.html#post2300995
 
Upvote 0
Thank you for your response @ Aladin Akyurek. I'm curious into why you avoid using the IFERROR function at all costs. I feel like it could be useful in certain scenarios, but then again I'm not an expert of excel. If you could share your thoughts I would love to learn more about it.
 
Upvote 0

Forum statistics

Threads
1,215,577
Messages
6,125,637
Members
449,242
Latest member
Mari_mariou

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