+ Reply to Thread
Results 1 to 5 of 5

String manipulation with exceptions

  1. #1
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    String manipulation with exceptions

    I have a macro that loops through a column of text and removes all text after a hyphen. Example: AU9929-PK becomes AU9929. I need to set up some exceptions that when it processes certain text it does not truncate it. Example: AU9929-ASST stays as AU9929-ASST. So far there are twelve exceptions but this could increase.

    Note: The list which includes shop number, description, sku, sku description, quantity, unit price and more is sorted in a particular order as other operations are performed on it that requires it be in a specific order.
    Last edited by Apel; 07-23-2009 at 02:13 PM.

  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481

    Re: String manipulation with exceptions

    Post the loop that you are currently using to truncate after the hyphen and we can give suggestions to modify your existing code to accomodate your exceptions?

  3. #3
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    Re: String manipulation with exceptions

    Here is the code.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481

    Re: String manipulation with exceptions

    In this If statement you can test for your exceptions and then NOT trim your SKU accordingly.

    Please Login or Register  to view this content.
    You will need to add a check for each of your exceptions.

    Please Login or Register  to view this content.
    which can get cumbersome as your number of excpetions increases. You may want to switch to using a Seclect Case statement to make this a little easier to manage as your exceptions change, etc.

    HTH

  5. #5
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    Re: String manipulation with exceptions

    Ahhh. Select case. I had forgotten about that guy. I knew there was something better than a 300 line if statement but I couldn't think of it. Thanks.

+ 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