+ Reply to Thread
Results 1 to 3 of 3

need to extract piece of string

  1. #1
    Registered User
    Join Date
    06-24-2009
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    1

    need to extract piece of string

    So I have a similar issue that I am trying to resolve. I have several cells (rows 2-*) that contain data like shown below;

    "Ad Size = 160x600","Make = JEEP","Search Type = All","Search Type = New","Search Type = Used"

    "Ad Size = 160x600","Model = Grand Cherokee","Make = JEEP","Search Type = All","Search Type = New","Search Type = Used"

    As you can see the strings are not particularly in any order so text to columns winds up further messing up the data. What I want to be able to do is create columns(B-E);

    Ad Size Make Model Body Style

    and if there is a value within the string for any of these to put it in the respective column. The catch, I cannot use left or right because the values can be anywhere in the string. I am running into difficulty using the mid formula because it requires me to specify the length of what I want returned which can vary.

    I guess the gist of what I'm looking for is a formula or VBA to scan a string and return the value that corresponds inside that string in another column. I want this to be smart enough to also determine how many characters are located between the "Ad Size = " and the next comma in order to return the entirety of the results.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    re: need to extract piece of string

    In cells B1:E1 enter the headings:

    Ad Size ; Make ' Model ; Body Style

    In cell B2, enter and copy across and down:

    =IF(ISERROR(SEARCH(B$1,$A2)), "" ,MID($A2,SEARCH(B$1,$A2)+LEN(B$1)+3, SEARCH("""", $A2, SEARCH(B$1, $A2))-SEARCH(B$1, $A2)-LEN(B$1)-3))

    HTH

    Jason

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    re: need to extract piece of string

    If your headers start in B1, then in B2, Try:

    Please Login or Register  to view this content.
    copied down and across....
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ 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