+ Reply to Thread
Results 1 to 10 of 10

Very Quick Question-Select Case-Determine if string has delimiters

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Talking Very Quick Question-Select Case-Determine if string has delimiters

    Just a very quick question.

    I need code to determine whether a given string contains common delimiters or not. I want the output as a Select Case/End Select. (i.e. first case = if string contains any of the following delimiters. Case else = string doesn't contain).

    The delimiters I want to capture are:
    • Space ( )
    • Comma (,)
    • Full stop/period (.)
    • Underscore (_)


    (I won't need "-" because of the danger of picking up hyphenated surnames).

    (Yes I could work this out myself but my solution would be large and messy. I am hoping for a quick compact solution here folks! )
    (Background Info: I intend to implement this code into another project I am working on: http://www.excelforum.com/excel-form...ngle-word.html
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    Hi MC,

    Something like this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    Quote Originally Posted by xladept View Post
    Something like this:
    Thanks for your help +1

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    Before I close the thread as solved, I want the code to be more compact/compressed.

    Why does xladepts code work but not the code below? (the code is an extract only)
    Please Login or Register  to view this content.
    Does anyone where the above code is going wrong?

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    That can't work because you never have " ,._" together as a string with nothing between them, maybe something like
    "* ,*.*_*" would work???

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    That can't work because you never have " ,._" together as a string with nothing between them, maybe something like"* *,*.*_*" would work??? And - you're welcome!

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    Quote Originally Posted by xladept View Post
    That can't work because you never have " ,._" together as a string with nothing between them, maybe something like"* *,*.*_*" would work??? And - you're welcome!
    The post #4 code was my attempt at adapting some other code I found a while ago. The original code is below.

    UPDATE 1: Just ran some tests on the function below and it always returns False. Uh oh.
    UPDATE 2: I found out where I found the code from. http://www.jpsoftwaretech.com/excel-...ate-filenames/ Interestingly the web page states: "I've modified the original code ever so slightly; the asterisks just inside the quotation marks in Ross' code are unnecessary, if the Visual Basic Help System is to be believed." (It looks like the asterisks ARE necessary)

    Please Login or Register  to view this content.
    Last edited by mc84excel; 04-28-2013 at 11:25 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    I will mark this thread as solved because my original question has been answered.

    (However I am still interested in a "like" version to make the delimiter check more compact. I am sure I can work this out myself once somebody solves this thread here: http://www.excelforum.com/excel-prog...file-name.html )

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

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Very Quick Question-Select Case-Determine if string has delimiters

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    Thanks! +1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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