I want to extract a substring from a cell in a column based on search match

andrebooyzen

New Member
Joined
May 30, 2023
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi All.
Great forum.
I have a column of data and I want to search the whole column for a match to name and then extract the first 5 characters from the cell that has a match. I have triend INDEX and MATCH and VLOOKUP with varying results.
Please help :)
Thanks

Typical cell in the column looks like this

09:00-10h30
Andre
Peter

I want to search all the cells in a specified column for a name eg Peter, and if it finds a match then return the first 5 characters of the cell.
 
Try:
Excel Formula:
=IFERROR(LEFT(VLOOKUP("*"&D2&"*",B4:B6,1,0),5),"")
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
It found 2 matches correctly in the column I searched. However it returned a 1 in one match and a 0 in the other match.
Could you give a small set of sample data where that issue arises and explain in relation to that?


However, when there is no match it returns a #N/A. Any way I can get rid of this?
You can target that error more specifically like this
Excel Formula:
=IFNA(LEFT(VLOOKUP("*"&D2&"*",B4:B6,1,0),5),"")
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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