Menu

Change Case and apostrophe

Help
epicode
2023-05-13
2023-05-13
  • epicode

    epicode - 2023-05-13

    When using "Capitalize each word" it recognizes apostrophe and minus as end of the word and capitalizes every letter after them like Tom'S
    Can there either be an exception for apostrophe and minus symbol by default since they are not end of word or at least an option to exclude them?

     

    Last edit: epicode 2023-05-13
  • epicode

    epicode - 2023-05-13

    I realized that this is not a problem of Essential Addin but default behaviour of Proper Function in Excel which does not respect ' and -

    I am using the following code to bypass the issue (sharing here for anyone with same issue or for Steve to include as part of Essential )

    Public Function ProperCase(ByVal str As String) As String
    
    Dim words As Variant
    Dim i As Long
    Dim word As String
    
    words = Split(str, " ", , vbTextCompare)
    
    For i = 0 To UBound(words)
    words(i) = UCase(Left(words(i), 1)) & LCase(Mid(words(i), 2))
    Next i
    
    ProperCase = Join(words, " ")
    
    End Function
    
     

    Last edit: epicode 2023-05-13

Log in to post a comment.