+ Reply to Thread
Results 1 to 6 of 6

Find a string in cell with multiple values based on number in another cell

  1. #1
    Registered User
    Join Date
    02-02-2015
    Location
    Massachusetts, USA
    MS-Off Ver
    2010
    Posts
    4

    Find a string in cell with multiple values based on number in another cell

    I have a column with multiple choices downloaded from Sharepoint. Each value is separated by a semi-colon. I found a wonderful VBA solution to duplicate rows based on the # of values in this cell on your site. Now, I want to select the specific string based on the # in that column. Example: Cell A1 contained: a; c; d; f.

    The macro duplicated this so that now I have 4 rows (2-5) with the exact same information in column A and numbering starting over at 1 for each new item in Column B. I am attaching a spreadsheet to illustrate.

    What I need is for Column C to display the value from Column A based on the number in Column B.
    I have indicated what the final result in Column C would be. Just don't know the formula or VBA code for accomplishing this.

    Whatever help you can provide would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,498

    Re: Find a string in cell with multiple values based on number in another cell

    How about:

    =MID(SUBSTITUTE(A2,";",REPT(" ",100)),(B2-1)*100+1,100)
    Quang PT

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,915

    Re: Find a string in cell with multiple values based on number in another cell

    C2=TRIM(MID(SUBSTITUTE(A2,";",REPT(" ",LEN(A2))),(B2-1)*LEN(A2)+1,LEN(A2)))
    Try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Registered User
    Join Date
    02-02-2015
    Location
    Massachusetts, USA
    MS-Off Ver
    2010
    Posts
    4

    Re: Find a string in cell with multiple values based on number in another cell

    Correction on earlier reply: This worked great for most of my list. I have some cells that contain more items than others. I'm not sure if there is a limit to this formula or if it's something else. One of my entries has 36 items (1208 characters and spaces) and the formula works fine. Another on my list has 47 (1575 characters and spaces) and I'm getting "#VALUE!" for a result. Any idea why this is happening?

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,915

    Re: Find a string in cell with multiple values based on number in another cell

    Try
    =MID(A2&";",FIND("^",SUBSTITUTE(";"&A2&";",";","^",B2)),FIND("^^",SUBSTITUTE(";"&A2&";",";","^^",B2+1))-fIND("^",SUBSTITUTE(";"&A2&";",";","^",B2))-1)
    or
    =LEFT(RIGHT(A2&";",LEN(A2)+2-FIND("^",SUBSTITUTE(";"&A2&";",";","^",B2))),FIND(";",RIGHT(A2&";",LEN(A2)+2-FIND("^",SUBSTITUTE(";"&A2&";",";","^",B2))))-1)

  6. #6
    Registered User
    Join Date
    02-02-2015
    Location
    Massachusetts, USA
    MS-Off Ver
    2010
    Posts
    4

    Re: Find a string in cell with multiple values based on number in another cell

    Both worked perfectly! I can't thank you enough!!!

+ 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 a string withing cell range and return cell number
    By visak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-16-2015, 09:19 PM
  2. Replies: 1
    Last Post: 09-10-2014, 08:21 PM
  3. Find Multiple Instances of a String, copy whatever number value is in next Cell and add it
    By arvind3tthiru in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2013, 11:26 PM
  4. [SOLVED] VBA Needed to find number/text within cell string and copy out to new cell
    By Campbell A in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-19-2013, 10:15 AM
  5. Find string in cell based on surrounding characters
    By Flemail in forum Excel General
    Replies: 2
    Last Post: 09-30-2010, 02:39 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