wildcard substring search

blossomthe2nd

Active Member
Joined
Oct 11, 2010
Messages
450
Hi Guys

I need a formula that looks at a cell and sees if it has CGB within the text and if so will return the full 16 digits inclusive of CGB, for ex

What Id like is
COLUMN A Formula Result
CGB1234567891011 ADE CGB1234567891011
ADEFE CGB1234567891011 CGB1234567891011
asw CGB1234567891011 fasfs CGB1234567891011

Can anyone help please ?
Thanks
 
Hi Sektor

If I understand the format correctly, by looking at the examples, it's "CGB" followed by 13 digits.

Your code will accept things like:

ABCGBJLOIJUDFR

Yes, pattern searches for "CGB" string assuming that CGB can appear inside of string, what "\w*" does. In authors examples it's clear that CGB is always in the beginning of the string, although author didn't state that.
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Yes, pattern searches for "CGB" string assuming that CGB can appear inside of string, what "\w*" does. In authors examples it's clear that CGB is always in the beginning of the string, although author didn't state that.

I agree, the format is not well specified by the OP.
 
Upvote 0
Hi

It's the "Original Poster", the person that started the thread.

Sometimes it' also used as the "Original Post", the first post in the thread.
 
Upvote 0
Hi Biz

You cannot use a character class ([...]) in this case to specify all the characters of the string, for ex., because the order is important in the letter part, "CGB".

Your udf will extract things like:

AAAAAAAAAAAAAAAA
1212121212121212

Hi pgc01,

Sorry I missed that.

Biz
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

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