LOOKUP function. Need first occurrence from the right, not left

SEASIA

New Member
Joined
Jul 23, 2022
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hello everybody. I'm new here and this is my very first post.

My Excel experience is limited but nevertheless created over time several sheets with success. However, now I'm stuck at this.

'Stock Options'!D3 contains .AAPL220729P140

What I need is this: Find the position of the first P from the right, but give out number of characters from the beginning (left) to that P. In this case the correct result would be 11. Not 4.

Those are stock option symbols. If there isn't a P in the stock symbol but only a P for Put my formula works. I'm using this formula:

=IFERROR(LOOKUP(2^15,SEARCH("P",'Stock Options'!D3,ROW(INDIRECT("1:"&LEN('Stock Options'!E3))))), "0")

I added IFERROR because if there is no P the result would be #n/a. But because I'm doing the same for the character C, I then need the function =MAX to determine the higher value. So I replaced #n/a with a 0.

The length of the symbols varies. Otherwise it would be easy when the P is always at the same position. But this is not the case. I hope this is possible without VBA because that would be a complete new world for me.
 
Glad you have something now that you are happy with. (y)
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,212,931
Messages
6,110,745
Members
448,295
Latest member
Uzair Tahir Khan

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