+ Reply to Thread
Results 1 to 8 of 8

Excel 2007 : Obtain number from web link

  1. #1
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Obtain number from web link

    Hi All,

    Need a little help here.

    I have data in the following format -

    http://www.friends.com/general/hobbies/123456-Andrea Timothy.html
    http://www.friends.com/crafts/234344-John Samuel.html

    This runs into several rows. How do i obtain just the numbers like 234344 and 123456 in a separate column? Text to columns doesn't work in this case.

    Thanks much.
    Last edited by arlu1201; 10-31-2011 at 02:40 PM. Reason: Edited the data provided.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Obtain number from web link

    Hi Arlu,

    If the number always immediately follows the last "/" and is then followed by a "-", you could use:

    =MID(SUBSTITUTE(A1,"/","^",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))),FIND("^",SUBSTITUTE(A1,"/","^",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))+1,FIND("-",A1)-FIND("^",SUBSTITUTE(A1,"/","^",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))-1)

    Assumes there are no carats in your text strings (^).

    Could also separate the formula into two columns, e.g.

    B1: =SUBSTITUTE(A1,"/","^",LEN(A1)-LEN(SUBSTITUTE(A1,"/","")))
    C1: =MID(B1,FIND("^",B1)+1,FIND("-",B1)-FIND("^",B1)-1)

    You could also use an array formula like:

    =1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$256),1)),0),COUNT(1*MID(A1,ROW($1:$256),1)))

    After typing this formula, you must press CTRL+SHIFT+ENTER, not just ENTER. (The 256 in the formula can be adjusted if your text strings are longer than 256 characters.)

    Hope that helps!

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Obtain number from web link

    Thank you so much Paul. This formula works perfectly with the 4 digit number. What if i have 6 digit numbers? Its giving me a #Value error for a 6 digit number.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Obtain number from web link

    Can anyone help me here?

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Obtain number from web link

    Bump No Response

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Obtain number from web link

    Can someone please help me here? I need to extract the 6 digit number from the links i have.

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Obtain number from web link

    Arlu,

    I tested the first formula I provided on your text strings and it worked just fine. I then tested it on numbers from 1 to 16 digits in length and had no problems either. Also, the last formula (array formula using CTRL+SHIFT+ENTER) also worked for numbers of varying digits.

    Perhaps your cells are formatted to only show so many digits or some odd configuration. Try my formula in a new worksheet with your test URL's. If you can't get it to work, post a copy of your workbook for review.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Obtain number from web link

    Thanks Paul, i got it to work with some minor tweaking. Actually, i should have included this part in my sample. Some of the links had "-" in between the words which was creating a problem. I changed it as below -
    =MID(SUBSTITUTE(B2,"/","^",LEN(B2)-LEN(SUBSTITUTE(B2,"/",""))),FIND("^",SUBSTITUTE(B2,"/","^",LEN(B2)-LEN(SUBSTITUTE(B2,"/",""))))+1,6)
    and it works perfectly. Thanks for all your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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