Removing special characters VBA Excel

后端 未结 4 570
北荒
北荒 2020-12-01 14:52

I\'m using VBA to read some TITLES and then copy that information to a powerpoint presentation.

My Problem is, that the TITLES have special characters, but Image fil

4条回答
  •  孤城傲影
    2020-12-01 15:08

    Here is how removed special characters.

    I simply applied regex

    Dim strPattern As String: strPattern = "[^a-zA-Z0-9]" 'The regex pattern to find special characters
    Dim strReplace As String: strReplace = "" 'The replacement for the special characters
    Set regEx = CreateObject("vbscript.regexp") 'Initialize the regex object    
    Dim GCID As String: GCID = "Text #N/A" 'The text to be stripped of special characters
    
    ' Configure the regex object
    With regEx
        .Global = True
        .MultiLine = True
        .IgnoreCase = False
        .Pattern = strPattern
    End With
    
    ' Perform the regex replacement
    GCID = regEx.Replace(GCID, strReplace)
    

提交回复
热议问题