View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default I need to search for then extract a specific portion of cell d

On Tue, 05 Sep 2006 21:11:27 -0400, Ron Rosenfeld
wrote:

I missed one.

What do you want returned for:

5054-SUA-US

I'm assuming you want a blank. If that is the case, change the formula to:

=REGEX.MID(A1,"(?<=\D)\d+",-1)


The following should be more "robust" depending on what you want. It's rule is
that it will return the last set of digits in the string only if they are NOT
followed by other alphanumeric characters.

=REGEX.MID(A1,"\d+(?!.*\w)",-1)

So this formula will return a null string ("") given:

5054-123-US


The first formula:

=REGEX.MID(A1,"(?<=\D)\d+",-1)

will return "123"


--ron