Find first instance of text in range of cells

spydey

Active Member
Joined
Sep 19, 2017
Messages
314
Office Version
  1. 2013
Platform
  1. Windows
I have a range. The cells contain a string in them.

The string consists of a date (mm/dd/yyyy) and either 1 of two words: Yes or No.

Example: [TABLE="width: 500"]
<tbody>[TR]
[TD]07/22/2015 - No[/TD]
[/TR]
</tbody>[/TABLE]

They are in a single cell, in a single column.

Regardless of I need to extract the date preceding the " - " from the first instance where the word is No.

Example:
[TABLE="width: 500"]
<tbody>[TR]
[TD]05/05/2015 - Yes[/TD]
[/TR]
[TR]
[TD]05/05/2015 - Yes[/TD]
[/TR]
[TR]
[TD]07/22/2015 - No[/TD]
[/TR]
[TR]
[TD]09/23/2015 - No[/TD]
[/TR]
[TR]
[TD]10/26/2015 - No[/TD]
[/TR]
[TR]
[TD]05/26/2016 - Yes[/TD]
[/TR]
[TR]
[TD]09/21/2016 - No[/TD]
[/TR]
[TR]
[TD]10/13/2018 - Yes[/TD]
[/TR]
</tbody>[/TABLE]

Regardless of how many Yes are before or after, regardless of how many No are after, I need the date associated with the first No in the list.

From my example list above, I would need the date of: 07/22/2015, because it is the date of the first iteration of the text "No".

I hope that makes sense.

I have tried multiple things, but nothing is getting me exactly what I need.

It would be so much easier if they were separated into individual columns (which I could do via Text to Columns), but I don't have the option to do that with this data set.

Any thoughts?

A formula or some VBA code to point me in the right direction would be greatly appreciated.

-Spydey

P.S. If I could simply isolate which cell the first iteration is in, then I could do a simple Left function and number of characters over to capture the date.

But isolating which cell the first iteration of "No" is in, is proving to be the difficult aspect. I believe primarily due to how I have been attempting it.
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Maybe...

=LEFT(INDEX(A1:A8,MATCH("*NO*",A1:A8,0)),10)

If you want a real date (number)
=--LEFT(INDEX(A1:A8,MATCH("*NO*",A1:A8,0)),10)

M.
 
Upvote 0
@ Marcela Branco

Thanks! I am going to give this an attempt.

-Spydey
 
Upvote 0
Maybe...

=LEFT(INDEX(A1:A8,MATCH("*NO*",A1:A8,0)),10)

If you want a real date (number)
=--LEFT(INDEX(A1:A8,MATCH("*NO*",A1:A8,0)),10)

M.


Hmmm, so I tried it and it isn't working. I tried it as a simple formula ... didn't work.

I tried it via CSE for an array formula. No go either.

I filled it down and still no results.

I think that we might be on the right path but that it needs a bit of tweaking.

-Spydey
 
Upvote 0
@ Marcelo Branco

I feel like such an moron.

I was entering the wrong word .... I apologize.

Your formula work great!!!

Thank you!!

-Spydey
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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