+ Reply to Thread
Results 1 to 9 of 9

Find first instance of a number after a value

  1. #1
    Registered User
    Join Date
    04-03-2007
    Posts
    28

    Find first instance of a number after a value

    I'm having trouble extracting text from a cell because there are so many variances.

    I've tried everything I can think of... to no avail.

    I need to display a number in a cell, this number is in another cell but surrounded by other text.

    The only thing I think is common among all cells, is that the number is the first number to follow ", " (a comma.. then space) [i.e] , 3 [/]

    is there a formula I can use to find the first number that comes after ", " is found?


    If you need more explanation please ask I will respond asap.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If it's always a one digit number then try

    =MID(A1,FIND(",",A1)+1,1)
    otherwise post some more info

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    04-03-2007
    Posts
    28
    yes, it is always a 1 digit number, but the problem is there may be multiple instances of the coma+space combination before the number.

    (X) ACETIC ACID, GLACIAL, 8,(3),UN2789, PGII Total
    (X) ACETIC ACID SOLUTION, 8,UN2790, PGII Total
    (X) CORROSIVE LIQUID, ACIDIC, INORGANIC, N.O.S. (PERCHLORIC ACID, CERRIC AMMONIUM NITRATE), 8, UN3264, PGIII Total
    (X) 4-METHYLMORPHOLINE, 3,UN2535, PGII Total

    I need to extract the bolded number from each of those.
    As you can see, there is differences in each... # of chars before and after the necessary character.


    Now that I look at it, even if I could just find the #, and pull that out (there are two of these in each...so I would need to extract the first instance of this)
    [two instances: the #, and there is a UN####, ( i dont need the UN#### ) ]

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    This would get 3 out of 4

    =IF(ISERROR(MID(A1,FIND(",UN",A1)-4,1)),MID(A1,FIND(", UN",A1)-1,1),MID(A1,FIND(",UN",A1)-1,1))
    If you can change the data then select the col > press Ctrl + H > in find box enter (?), and leave the replace box empty

    HTH

    VBA Noob

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Find first instance of a number after a value

    With
    A1: (a typical text entry...like you posted)

    Try this
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Nice one Ron

    VBA Noob

  7. #7
    Registered User
    Join Date
    04-03-2007
    Posts
    28
    thank you very much

  8. #8
    Registered User
    Join Date
    04-03-2007
    Posts
    28
    Well I just saw RONS post...

    VBA NOOB, yours worked for %90 of it... I am just playing with the oddball ones (removing (?)...etc.) to make it work 100%

    I will try the other posted as well

  9. #9
    Registered User
    Join Date
    04-03-2007
    Posts
    28
    Thank you both very much.

    Both worked about the same, due to the inconsistent text strings, it's the best I could hope for, I only have to change about 10-15 and I'm all set.
    You both just saved me a whole lot of hassle.

    THANKS!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find Column Number and then use Index Function
    By modytrane in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-03-2008, 12:59 PM
  2. Find next avaliable number in out of sequence column
    By Kudos247 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-25-2008, 09:21 PM
  3. Find last number and insert
    By jackhowson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2007, 06:37 AM
  4. How to find and go to a specific row number?
    By The student in forum Excel General
    Replies: 5
    Last Post: 06-26-2007, 09:01 AM
  5. Find the Last number in a column
    By new@this in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2007, 09:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1