Formula to find specific text in a column then return last value in same row

MrSamExcel

Board Regular
Joined
Apr 6, 2016
Messages
50
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
My file has two sheets: 'Formula' and 'Class1'. Is there a formula – non-array, not VBA – that I can place in ‘Formula’ sheet -> cell B2 that will find the first occurrence of text “Monthly Return” in ‘Class1’ sheet -> column A and return the last / right-most populated value in the same row? In my example, the result of the formula would be 9.99%.

You can see my current LOOKUP formula in B2 on the ‘Formula’ sheet only works if I manually specify the row for each time period. Ex) For the 1 mo period I specified $A7:$Z7, but would be better if formula could find row that begins with “Monthly Return” from ‘Class1’ sheet. Thanks.

Find text and return value in last cell of same row.xlsx
ABCD
11 moYTD1 yr
2Class19.99%8.88%1.11%
Formula

Find text and return value in last cell of same row.xlsx
ABCDEFGHI
1Class1
2Date
3
4Quarter Ending12/31/201812/31/20186/30/20196/30/20196/30/20239/30/20239/30/2023
5Month Ending11/30/1812/31/185/31/196/30/196/30/237/31/238/31/23
6Static3.50%3.50%3.50%3.50%3.50%
7Monthly Return5.00%6.00%7.00%8.00%9.99%
8
9
10YTD0.64%0.74%1.26%1.51%1.68%
11YTD Return6.00%7.00%8.00%8.88%
12
131 Year Return7.00%8.00%1.11%
Class1
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about:

Excel Formula:
=LET(a,FILTER(Class1!A1:Z20,Class1!A1:A20="Monthly Return"),LOOKUP(2,1/(a<>""),a))
 
Upvote 1
Solution
How about:

Excel Formula:
=LET(a,FILTER(Class1!A1:Z20,Class1!A1:A20="Monthly Return"),LOOKUP(2,1/(a<>""),a))
This is great, thank you!
I haven't used the LET function before, reading about it now. My understanding is that FILTER returns only the row from Class1 tab that begins with my specified text. Then LET names that row "a". Then I can use the original LOOKUP to return the last value in the row we've named "a".
 
Upvote 0
Add'l thoughts as I learn about LET, in case this helps future readers: The LET function in this formula is optional, it simply serves to make the formula shorter/tidier.
FILTER is the critical element that convert my original LOOKUP from manual row number assignment to text-match row assignment. So the following would also work:
Excel Formula:
=LOOKUP(2,1/(FILTER(Class1!$A$1:$Z$20,Class1!$A$1:$A$20="Monthly Return")<>""),FILTER(Class1!$A$1:$Z$20,Class1!$A$1:$A$20="Monthly Return"))

For my use case, I still prefer the LET approach proposed by DanteAmor, as I think it will be easier to maintain for the team I will hand this over.
 
Upvote 1

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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