Find and return 2nd instance of value in column

srice33

New Member
Joined
Sep 18, 2024
Messages
3
Office Version
  1. 365
Platform
  1. MacOS
I have a specific text string that I am trying to return the value for from within a column of data. I want to return the date portion of the text string for the second occurrence of the text string.

For example, the text string begins with "As of" and ends with a date. I.e. "As of 05/06/2024".

There are numerous text strings like this within the column (i.e. first instance might be "As of 07/01/2024" in row 1, second instance "As of "09/15/2024" in a later row), and I want to return the second instance when the string begins with "As of".

The return value needs to be just the date portion of the string, i.e. 09/15/2024.

1726684567755.png
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Assuming that first column is in column A, how about:

Excel Formula:
=TEXTAFTER(INDEX(FILTER(A:A,LEFT(A:A,5)="As of"),2),"As of ")
 
Upvote 0
Another option, but will find "As of" anywhere in the string, not just the beginning:
Book1
AB
1
2As of 7/1/20249/15/2024
3sample text
4sample text
5sample text
6sample text
7sample text
8sample text
9sample text
10sample text
11sample text
12sample text
13sample text
14As of 9/15/2024
15sample text
16sample text
17sample text
18sample text
19sample text
20sample text
21sample text
22sample text
23sample text
24sample text
25sample text
Sheet1
Cell Formulas
RangeFormula
B2B2=TEXTAFTER(CHOOSEROWS(FILTER(A2:A25,ISNUMBER(SEARCH("As of ",A2:A25))),2),"As of ")
 
Upvote 0
Much appreciated - is there any alternative to the text after function? I am having to use sheets and it is not supported.
 
Upvote 0
Much appreciated - is there any alternative to the text after function? I am having to use sheets and it is not supported.
You can use RIGHT and LEN like this:

=RIGHT(INDEX(FILTER(A:A,LEFT(A:A,5)="As of"),2),LEN(INDEX(FILTER(A:A,LEFT(A:A,5)="As of"),2))-6)

=RIGHT(CHOOSEROWS(FILTER(A2:A25,ISNUMBER(SEARCH("As of ",A2:A25))),2),LEN(CHOOSEROWS(FILTER(A2:A25,ISNUMBER(SEARCH("As of ",A2:A25))),2))-6)
 
Upvote 0
Solution
You can use RIGHT and LEN like this:

=RIGHT(INDEX(FILTER(A:A,LEFT(A:A,5)="As of"),2),LEN(INDEX(FILTER(A:A,LEFT(A:A,5)="As of"),2))-6)

=RIGHT(CHOOSEROWS(FILTER(A2:A25,ISNUMBER(SEARCH("As of ",A2:A25))),2),LEN(CHOOSEROWS(FILTER(A2:A25,ISNUMBER(SEARCH("As of ",A2:A25))),2))-6)
Got it to work, thank you!!
 
Upvote 0
I am having to use sheets and it is not supported.
As you can see, while there are many similarities between Excel and Google Sheets, they are NOT same. As such, you should not post Google Sheets questions in the "Excel Questions" forum. You should post them to the "General Discussion & Other Applications" forum (note the description on it):

1726689642094.png


Also, we recommend that you either mention in your title and/or original question that you are using Google Sheets, since this forum is for all other programs (not just Google Sheets).
Then it will be clear to users exactly which program you are working on.

I have moved this thread to the appropriate forum.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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