LOOKUP and SEARCH functions to return a value within a string and accounting for blanks

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
5,365
Office Version
  1. 365
Platform
  1. Windows
Hi all,

In cell A2 I have the following string:

0>5>10>15>20>25>30

In B2:B27 of a tab called Scope the numbers i.e. 0, 1, 2... are listed. I'm using the following formula to match the number...

=LOOKUP(1,0/SEARCH(Scope!$B$2:$B$27,A2),Scope!$B$2:$B$27)

...which works fine if there are no blanks. How can I account for blanks in the formula?

I'm using Office 365 so maybe there's an alternative function like FILTER though I's still like so get my original formula working.

Many thanks,

Robert
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
which works fine if there are no blanks.
No blanks where?
  • Within the A2 string?
  • Blank cells in Scope B2:B27?
  • Somewhere else?
Can you give us some sample data where the formula is not doing what you want and also tell us the expected result for that data?
 
Upvote 0
Hi Peter,

Yes - no blanks in the range B2:B277 of the Scope tab. When there is a zero is returned.

Thanks,

Robert
 
Upvote 0
Yes - no blanks in the range B2:B277 of the Scope tab. When there is a zero is returned.
I assume that you meant B27 not B277 but in any case the current formula result depends on where the blanks are in that range. So this would still be useful ..
Can you give us some sample data where the formula is not doing what you want and also tell us the expected result for that data?
 
Upvote 0
Hi Peter,

Thanks for your reply. I will try and upload later when I'm at home.

This formula is the closest of what I'm after but if there's a blank or no match in Col. B it strangely returns that entry from Col. A (which I want) for each cell the formula is in:

=XLOOKUP(TRUE,ISNUMBER(SEARCH(Scope!$B$2:$B$27,A2)),Scope!$A$2:$A$27,0)

Any advice would be appreciated.

Regards,

Robert
 
Upvote 0
I'm using Office 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

From the data on your cross post, how about
Excel Formula:
=LET(x,XLOOKUP(--TEXTSPLIT(B3,">"),Scope!$B$2:$B$7,Scope!$A$2:$A$7,""),TAKE(FILTER(x,x<>"",""),,1))
 
Upvote 1
Solution
Hi Fluff,

I have updated my account. Thanks.

The formula looks good though is it possible to return a blank if there's no match instead of returning the first item in the list i.e. for 8>7>6>9 your formula returns "Zero".

Many thanks,

Robert
 
Upvote 0
Actually never mind. All working now 👍

I appreciate your response 😎
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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