Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-06-2022, 07:45 AM
Souriane Souriane is offline Cleaning string Windows 10 Cleaning string Office 2019
Advanced Beginner
Cleaning string
 
Join Date: Feb 2017
Location: Quebec, Canada
Posts: 82
Souriane is on a distinguished road
Post Cleaning string

Hi!

Macropod gave me this macro 10 years ago. Still using it! It changes all accented letters to non-accented letters. But I can't figure out how to modify it in order that spaces be replaced by underscore?



Code:
Function CleanString(StrInput As String) As String
'Enlève les caractères accentués d'une chaîne
'Auteur : Macropod 2011-04-01

    Dim StrOutput As String, StrChr As String, i As Integer
    For i = 1 To Len(StrInput)
        StrChr = Mid$(StrInput, i, 1)
        Select Case AscW(StrChr)
        Case 192 To 197: StrChr = "A"
        Case 198: StrChr = "AE"
        Case 199: StrChr = "C"
        Case 200 To 203: StrChr = "E"
        Case 204 To 207: StrChr = "I"
        Case 208: StrChr = "D"
        Case 209: StrChr = "N"
        Case 210 To 214, 216: StrChr = "O"
        Case 215: StrChr = "x"
        Case 217 To 220: StrChr = "U"
        Case 221: StrChr = "Y"
        Case 222, 254: StrChr = "p"
        Case 223: StrChr = "B"
        Case 224 To 229: StrChr = "a"
        Case 230: StrChr = "ae"
        Case 231: StrChr = "c"
        Case 232 To 235: StrChr = "e"
        Case 236 To 239: StrChr = "i"
        Case 240, 242 To 246, 248: StrChr = "o"
        Case 241: StrChr = "n"
        Case 249 To 252: StrChr = "u"
        Case 253, 255: StrChr = "y"
        End Select
        If StrChr Like "[A-Za-z0-9_]" Then
            StrOutput = StrOutput & StrChr
        End If
    Next
    CleanString = StrOutput
End Function
Thank you!

Souriane
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cleaning string Cleaning up Text anon125 Word 12 02-26-2018 06:31 PM
Cleaning string Cleaning up a database doctormathis Excel 9 08-10-2017 06:58 AM
Cleaning then managing inbox ash_scotland88 Outlook 0 11-28-2016 06:04 AM
Cleaning string Cleaning up Text Pasted from Websites, E-mails, PDFs etc. macropod Word 0 02-06-2016 02:09 PM
Cleaning string Unable to download Microsoft Office 2010 after cleaning system Warxfreedom Office 3 01-15-2016 11:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft