+ Reply to Thread
Results 1 to 5 of 5

Remove part of a string before adding to New Collection

  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Question Remove part of a string before adding to New Collection

    G'day everyone,

    Im using the following code to create a validation list. My question is this - how could I modify the string value to exclude a specified term.
    I.e. If the cell.value found makes it thru to the line
    Please Login or Register  to view this content.
    and this value is "Fld Coordinator OH", then could i include an extra line before adding it to the collection so that if it contains "Fld Coordinator" then this term is removed, leaving only "OH" as the value to be added to the collection?


    Please Login or Register  to view this content.
    Thanks heaps

  2. #2
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Remove part of a string before adding to New Collection

    may be something like this...
    Please Login or Register  to view this content.
    Regards,
    Vandan

  3. #3
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Re: Remove part of a string before adding to New Collection

    thank you for your reply vandan, this works great.
    My only question is what if i wanted it to be more broad, such that the user could define any term they wanted for it to exclude, and it could determine where in the string the term is and is able to remove it.
    an example could be

    rmStr = Collar
    eg.1
    Cell.Value = 'Blue Collar'
    newStr = Blue
    eg.2
    Likewise if Cell.value = Collar Excel
    newStr = Excel

    regards
    Last edited by jordan2322; 07-11-2012 at 01:15 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Remove part of a string before adding to New Collection

    One way
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Remove part of a string before adding to New Collection

    I like jindon's way. it is a bit more neater than mine.

    One suggestion I have is to may be have an array with a list of string you want to remove and then processing the cell value through it to remove all unwanted strings. This could be done in a separate function.

+ 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