+ Reply to Thread
Results 1 to 2 of 2

Search String and Return Static Value (Like CASE + RegEX in SQL)

  1. #1
    Registered User
    Join Date
    10-29-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    1

    Question Search String and Return Static Value (Like CASE + RegEX in SQL)

    I'm trying to help out the wife with a task at work, and it's been a very long time since I've done any programming in either Excel or VB.

    Essentially she has a column of values in varying formats, and, depending on which format they match, she needs to return a set value in another cell. In SQL this could easily be accomplished with a CASE statement combined with RegExLike, but I can't seem to figure out the equivalent for Excel.

    Here are some examples of the possible input strings - where # represents a numeric, and A represents any alpha character. I think some of them have some special characters - like ( ) - but otherwise they follow these patterns.

    ##-##A
    #-##A
    #-##AAA
    #-###A

    And so on. The idea is to match the pattern and then return a corresponding value - since the input values can change, using a VLOOKUP doesn't really work, since you'd have to rebuild the lookup table every time, and by the time you're done you could have just done it by hand.

    Any thoughts/suggestions?

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Search String and Return Static Value (Like CASE + RegEX in SQL)

    Hi

    Maybe a UDF?

    Please Login or Register  to view this content.
    If that doesn't do it, then put up an example file, showing the relevant string possibilities, and what it should return.

    HTH

    rylo

    rylo

+ 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