How do I shorten the following repetitive Lookup formula?

Ngamia

New Member
Joined
Apr 26, 2021
Messages
20
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
Hi everyone,

I have the following formula that retrieves the last value in a column B

Excel Formula:
=LOOKUP(2,1/(Quarterly_Sales!B:B<>""),Quarterly_Sales!B:B)

The values in column B are an alphanumeric sequence, SN2023-1234, and I need to extract the number after the dash - which I can do so using the formula below.

Excel Formula:
=RIGHT(A1,LEN(A1)-FIND("-",A1))

However when I now combine the two formulas by replacing A1 with the first formula, it becomes the unwieldy mess below.

Excel Formula:
=RIGHT(LOOKUP(2,1/(Quarterly_Sales!B:B<>""),Quarterly_Sales!B:B),LEN(LOOKUP(2,1/(Quarterly_Sales!B:B<>""),Quarterly_Sales!B:B))-FIND("-",LOOKUP(2,1/(Quarterly_Sales!B:B<>""),Quarterly_Sales!B:B)))

I am looking for a way to shorten this formula.
 

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".
You can use the LET function to assign the repeating part of your formula to a variable, so you can use that variable in your formula to shorten it up.
See: LET function - Microsoft Support
 
Upvote 0
I think your final formula using LET would look something like this:
Excel Formula:
=LET(x,LOOKUP(2,1/(Quarterly_Sales!B:B<>""),Quarterly_Sales!B:B),RIGHT(x,LEN(x)-FIND("-",x)))
 
Upvote 0
Solution
How about
Excel Formula:
=textafter(LOOKUP(2,1/(Quarterly_Sales!B:B<>""),Quarterly_Sales!B:B),"-")
 
Upvote 0
Another option:

Excel Formula:
=IFERROR(TEXTAFTER(XLOOKUP(TRUE,Quarterly_Sales!B:B<>"",Quarterly_Sales!B:B,"",0,-1),"-"), "No Dash In Result")
Without the error handling
Excel Formula:
=TEXTAFTER(XLOOKUP(TRUE,Quarterly_Sales!B:B<>"",Quarterly_Sales!B:B,"",0,-1),"-")
 
Upvote 0
Thanks all for your suggestions.

I just realised that I forgot to update my profile to indicate that I no longer have the MS-365 subscription.
The economic conditions finally made it impossible to keep it.
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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