+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    02-27-2010
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2007
    Posts
    3

    VLOOKUP: ignore first 58 characters in cell, return value, export XML

    I have 2 spreadsheets:
    1 - list of filenames, title, description
    2 - list of filenames with paths (and additional information)

    Can't figure out how to write the VLOOKUP so it ignores the first 58 characters (which are the path) and matches the filename so I can return the title: description in spreadsheet 2, then export to XML.

    Spreadsheet 2 originated as an XML file so there's that to work with as well if it makes a difference.

    Any help would be greatly appreciated. Thank you!

  2. #2
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,044

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    Where would you want Vlookup to ignore the first 58 characters? In the lookup value or the lookup table first column? A data sample might do wonders to help comprehension. One of the good things in this forum is that you can upload files.

    You can upload a file by clicking "Go Advanced" below the Quick Reply box and then the paper clip icon.
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

  3. #3
    Forum Guru rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    Hi Teylyn,

    here's your upload. Maybe you can do a better job than I.

    HTML Code:
    =VLOOKUP(MID(A2,1+MAX(IF(MID(A2,ROW($A$1:$A$100),1)="\",ROW($A$1:$A$100))),LEN(A2)-MAX(IF(MID(A2,ROW($A$1:$A$100),1)="\",ROW($A$1:$A$100)))),Sheet1!A1:C4,2,FALSE)
    My formula lookup up the last "\" and reads from that point on.

    I've seen other (better) constructions, but I leave it to others to optimize.
    Attached Files Attached Files
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,479

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    alternatively try
    =VLOOKUP(TRIM(RIGHT(SUBSTITUTE(A2,"\",REPT(" ",50)),30)),Sheet1!$A$1:$C$4,2,FALSE)
    edit
    of course if you know file path is always 58 char including the final \ then =VLOOKUP(MID(A2,59,255),Sheet1!$A$1:$C$4,2,FALSE)
    Last edited by martindwilson; 02-28-2010 at 08:34 AM.
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,044

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    I have a feeling that the lookup value is only the file name, but the first column of the lookup table contains the whole path.

    Up to the OP to clarify.
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

  6. #6
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,479

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    yes you could be correct hmm then its simply this format
    =VLOOKUP("*"&A2,Sheet2!$A$14:$B$17,2,FALSE) where a2 =filename.xls Sheet2!$A$14:$B$17 =full paths with filename
    as long as the filename contains the file extension .xls .txt,.doc and so on it will find it as there couldnt be instances like that in the file path.
    Last edited by martindwilson; 02-28-2010 at 08:42 AM.
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Registered User
    Join Date
    02-27-2010
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    Thanks for the responses!

    Due to the difference in the file names I can't lookup past the final / unfortunately...it has to match past character 46 (sorry about the 58...was late and my math was broke) and somehow ignore the underscores. I guess I could do a find/replace to remove spaces and replace with underscores to eliminate that issue.

    I've attached the two spreadsheets. Copy of gallery.xlsx is where I was placing the VLOOKUP to return the match from column 2 of the other. Would there be an easy way to return both columns 2 and 3 separated by ": "?
    Attached Files Attached Files

  8. #8
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,479

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    can/t see what you need. give an example
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    02-27-2010
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VLOOKUP: ignore first 58 characters in cell, return value, export XML

    I placed the VLOOKUP from martindwilson's post in column DO and it worked great! THANK YOU!!!!!

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.2.0