+ Reply to Thread
Results 1 to 10 of 10

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

Hybrid View

  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

    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)
    Private Function UserNameToFirstLast(strUserName As String) As String
    '   test delimiters
        Dim DeLim As Boolean
        If (strUserName Like " ,._") Then
            DeLim = True
        End If
    
    'end of extract
    End Sub
    Does anyone where the above code is going wrong?
    *******************************************************

    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

    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!
    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
    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)

    Public Function IsLegalFileName(ByVal str As String) As Boolean
    '' refer http://msdn.microsoft.com/en-us/library/aa365247.aspx for list of invalid characters
        If (str Like "<>:""/\|?*") Then
            IsLegalFileName = True
        End If
    End Function
    Last edited by mc84excel; 04-28-2013 at 11:25 PM.

+ 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