View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Search for number after specific text in string

On Fri, 4 Sep 2009 03:26:01 -0700, AMH wrote:

I want to search for a number after a specific piece of text in a string, the
number can be 1 to 4 characters in length and will finish with either a comma
or a space, format like this :

.mpp\????, or .mpp\???? (with the question marks being numeric between 1
and 9999)

Any help would be much appreciated


One way would be to download and install Longre's free morefunc.xll add-in (use
Google to find a source), and then use this Regular Expression formula:

=REGEX.MID(A1,"(?<=\.mpp\\)\d+")

OR you could use this formula:

=TRIM(LEFT(SUBSTITUTE(SUBSTITUTE(MID(A1,FIND(
".mpp\",A1)+5,255),","," ")," ",REPT(" ",99)),99))
--ron