View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] fdb_biz@bloomingdalecom.net is offline
external usenet poster
 
Posts: 13
Default Extracting numbers greater than 5 digits from a string (variable position)

Hi. I've got a macro that imports the filenames of a users
investigation log into column A of a workbook and also hyperlinks
those files. Works well. I have a need to extract the product number
from each filename and put it in column B. Here is an example
filename:

1234001000-234156-357248 Screw (loose)

This breaks down to:
Product ID-investigation#-inquiry# Component (issue)

So, I need to extract that first number. But, it's not just that
simple. Here are the few complications:

1) That larger number may be anywhere in the string.
2) That number may have a letter suffix (e.g., 1234001000E)
3) Most people use dashes, but some use commas or spaces

The other numbers in the string are currently 6 digits, but at some
point it will go to 7 and maybe 8 (but not for a long time for 8).

I've found formulas and even VBA (and UDF) to extract a number, but
it's the variables that are complicating this for me. I'm thinking
maybe a a case structure or something along those lines, but how to
keep this flexible is eluding me. Any ideas? Thanks!

Frank