+ Reply to Thread
Results 1 to 8 of 8

Searching a comma delimited string in a cell

  1. #1
    Registered User
    Join Date
    11-26-2007
    Posts
    4

    Searching a comma delimited string in a cell

    Hi there.
    I'm putting together two work sheets for a cost analysis spread sheet.

    In one sheet, the user inputs the following:

    1. Description i.e. Shovel
    2. Cost i.e. $15.00
    3. What years cost occurs i.e. 0,4, 10, 19

    On the other sheet, have the cash flow model with the following

    Description
    Year Shovel
    0
    1
    2
    3... all the way to 50.

    What I want to do is have the column that shows the description at the particular year, to pull the info from the "What Year Cost Occurs" and drop it into the particular cell for that year.

    I was first using this function =IF(ISNUMBER(SEARCH($A3,Costs!$C8)),Costs!$B3, "0")

    to compare the cell with the data showing the comma delimited string but the problem is that it if a cost occurs in year 10, it reads the 10 as a 1 and a zero so it assumes that year 1 occurs when year 10 is listed.
    Any VB scripts out there that can help?
    I guess the best way is to take the string, convert it into an array, then search the array, then return the value of the cost if the number matches the array value.


    Any help is appreciated.
    Migpics

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

    =IF(ISNUMBER(SEARCH($A3&",",$C8&",")),$B3,0)
    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.

  3. #3
    Registered User
    Join Date
    11-26-2007
    Posts
    4
    Tried it but it still pulled the number from the spreadsheet.
    I attached the file to look at.
    Thanks
    migpics

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    The file didn't attach...

    you have to zip the file first. (Note: please save as an Excel2003 file and then zip it).

  5. #5
    Registered User
    Join Date
    11-26-2007
    Posts
    4

    Repost

    Oops.
    I didn't catch that.
    Here it is in Zip format.
    thanks
    migpics
    Attached Files Attached Files

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Ok...slight adjustment in my original formula to deal with trailing 0's.....

    Please Login or Register  to view this content.
    see attached...
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-26-2007
    Posts
    4
    Sweet! That works!
    I have to really dig into it so see how it works but it does.
    The next step will probably be to refine it with some VB to allow the user to say that costs occur every 2 or 3 or 4 years etc.
    Thanks.
    migpics

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

    that last 0 should really be on it's own and with quotes...in order for the result to be truly a 0 and not a text string..... i fixed it the 1st time, but forgot to fix it again.

    i.e..

    Please Login or Register  to view this content.

+ 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