+ Reply to Thread
Results 1 to 8 of 8

Getting a Vlookup to return a 'trimmed' value

  1. #1
    Registered User
    Join Date
    10-07-2014
    Location
    Norwich, England
    MS-Off Ver
    365
    Posts
    58

    Getting a Vlookup to return a 'trimmed' value

    Hello

    I have the following vlookup formula..

    =IF(A5="","",VLOOKUP(A5,'Portfolio Overview'!C:D,2,FALSE))

    Depending on what's in cell A5, it can return one of five values..

    Pipeline: Start Up
    Pipeline: Pre-Initiation
    In-Flight: Initiation
    In-Flight: Delivery
    In-Flight: ELS & Close

    I would like it to return just the text after the space, instead of the entire cell, so..

    Start Up
    Pre-Initiation
    Initiation
    Delivery
    ELS & Close

    Appreciate any help..

    Many thanks
    Tom

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Getting a Vlookup to return a 'trimmed' value

    Is it only those 2 possible pre-texts ? Pipeline: or :In-Flight: ?

    If so, try

    =IF(A5="","",TRIM(REPLACE(VLOOKUP(A5,'Portfolio Overview'!C:D,2,FALSE),1,10,"")))

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2310
    Posts
    13,357

    Re: Getting a Vlookup to return a 'trimmed' value

    To make the formula easy, perhaps first add a helper column ( that can be hidden say col D ) with your formula, and in the result column something like =right(d1,len(D1)-search(":",d1)-1)

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    42,965

    Re: Getting a Vlookup to return a 'trimmed' value

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    10-07-2014
    Location
    Norwich, England
    MS-Off Ver
    365
    Posts
    58

    Re: Getting a Vlookup to return a 'trimmed' value

    Many thanks for all your suggestions.. I used TNS's and it works perfectly. I have another similar formula I wonder if you could help me with though?

    I need exactly the same value returned, but I'm using an Index Match formula as the column I'm looking up against (F) is to the right of the column with the value I would like returned (D).

    =IF(B47="","",INDEX('Portfolio Overview'!D:D,MATCH('Portfolio Gantt'!B47,'Portfolio Overview'!F:F,0)))

    Again, the possible values returned depending on cell B47 are..

    Pipeline: Start Up
    Pipeline: Pre-Initiation
    In-Flight: Initiation
    In-Flight: Delivery
    In-Flight: ELS & Close

    And I'm trying to get it to return whatever appears after the space, so..

    Start Up
    Pre-Initiation
    Initiation
    Delivery
    ELS & Close

    Many thanks for your help.

    Regards
    Tom

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    42,965

    Re: Getting a Vlookup to return a 'trimmed' value

    Can't you just swap the INDEX/MATCH for the VLOOKUP?

  7. #7
    Registered User
    Join Date
    10-07-2014
    Location
    Norwich, England
    MS-Off Ver
    365
    Posts
    58

    Re: Getting a Vlookup to return a 'trimmed' value

    I didn't think I could use the VLOOKUP function when the column of the value I want returned is to the left of the column I'm looking up against?

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    42,965

    Re: Getting a Vlookup to return a 'trimmed' value

    No, you can't (strictly speaking, although there is a way ... don't ask). That isn't what I meant. Where you have a VLOOKUP formula in the original solution, replace each occurrence of that VLOOK formula withe your INDEX/MATCH formula. The INDEX/MATCH will return a string which can be operated on by the MID function.


    Untested:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS

+ 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. Trim and Keep the Trimmed Data
    By sally t in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  2. Trim and Keep the Trimmed Data
    By N Harkawat in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 11:05 AM
  3. Trim and Keep the Trimmed Data
    By sally t in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  4. Trim and Keep the Trimmed Data
    By sally t in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. [SOLVED] Trim and Keep the Trimmed Data
    By sally t in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-26-2005, 10:05 AM

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