+ Reply to Thread
Results 1 to 7 of 7

Find and Replace Macro to replace list of special characters

  1. #1
    Registered User
    Join Date
    12-22-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    15

    Find and Replace Macro to replace list of special characters

    Hello,

    Any VBA experts that could help with a Macro that can replace special/foreign characters with English equivalent across a whole worksheet?

    Basically, our internal system corrupts when we try and upload the characters, rather than doing find and replace several times it would be good to do it at a click!

    Below is what I need to find and replace. If someone can help with the "start" and "end" of the Macro and one example (if the below format is incorrect), I can populate the rest.
    Thanks in advance.

    fnd = "ø"
    rplc = "o"

    fnd = "ã"
    rplc = "a"

    fnd = "Š"
    rplc = "S"

    fnd = "Ž"
    rplc = "Z"

    fnd = "š"
    rplc = "s"

    fnd = "ž"
    rplc = "z"

    fnd = "Ÿ"
    rplc = "Y"

    fnd = "À"
    rplc = "A"

    fnd = "Á"
    rplc = "A"

    fnd = "Â"
    rplc = "A"

    fnd = "Ã"
    rplc = "A"

    fnd = "Ä"
    rplc = "A"

    fnd = "Å"
    rplc = "A"

    fnd = "Ç"
    rplc = "C"

    fnd = "È"
    rplc = "E"

    fnd = "É"
    rplc = "E"

    fnd = "Ê"
    rplc = "E"

    fnd = "Ë"
    rplc = "E"

    fnd = "Ë"
    rplc = "E"

    fnd = "Ì"
    rplc = "I"

    fnd = "Í"
    rplc = "I"

    fnd = "Î"
    rplc = "I"

    fnd = "Ï"
    rplc = "I"

    fnd = "Ð"
    rplc = "D"

    fnd = "Ñ"
    rplc = "N"

    fnd = "Ò"
    rplc = "O"

    fnd = "Ó"
    rplc = "O"

    fnd = "Ô"
    rplc = "O"

    fnd = "Õ"
    rplc = "O"

    fnd = "Ö"
    rplc = "O"

    fnd = "Ù"
    rplc = "U"

    fnd = "Ú"
    rplc = "U"

    fnd = "Û"
    rplc = "U"

    fnd = "Ü"
    rplc = "U"

    fnd = "Ý"
    rplc = "Y"

    fnd = "à"
    rplc = "a"

    fnd = "á"
    rplc = "a"

    fnd = "â"
    rplc = "a"

    fnd = "ã"
    rplc = "a"

    fnd = "ä"
    rplc = "a"

    fnd = "å"
    rplc = "a"

    fnd = "ç"
    rplc = "c"

    fnd = "è"
    rplc = "e"

    fnd = "é"
    rplc = "e"

    fnd = "ê"
    rplc = "e"

    fnd = "ë"
    rplc = "e"

    fnd = "ì"
    rplc = "i"

    fnd = "í"
    rplc = "i"

    fnd = "î"
    rplc = "i"

    fnd = "ï"
    rplc = "i"

    fnd = "ð"
    rplc = "o"

    fnd = "ñ"
    rplc = "n"

    fnd = "ò"
    rplc = "o"

    fnd = "ó"
    rplc = "o"

    fnd = "ô"
    rplc = "o"

    fnd = "õ"
    rplc = "o"

    fnd = "ö"
    rplc = "o"

    fnd = "ù"
    rplc = "u"

    fnd = "ú"
    rplc = "u"

    fnd = "û"
    rplc = "u"

    fnd = "ü"
    rplc = "u"

    fnd = "ý"
    rplc = "y"

    fnd = "ÿ"
    rplc = "y"

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,815

    Re: Find and Replace Macro to replace list of special characters

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    12-22-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    15

    Re: Find and Replace Macro to replace list of special characters

    Hello,

    Thanks for replying, see attached (this is a small snippet of the data)

    So for example, I would normally go to "Find and Replace" and replace ø with o then replace all. Then I would so the same with the a in Sao Paolo and so on. When I have hundreds of addresses I have to go through x amount of characters in find and replace. Ideally, I would like to have a macro that finds any offending characters and replaces them with the correct "English" letter (according to that list).

    I know there will be more to the code, as in, find ø, and replace all with o, if none found, move onto the next one and repeat the process.

    Is the below correct for one character and can I simply copy/paste from selection.find to add additional characters in?

    Sub SimpleReplace()

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "ø"
    .Replacement.Text = "o"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    Attached Files Attached Files

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,815

    Re: Find and Replace Macro to replace list of special characters

    Try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-22-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    15

    Re: Find and Replace Macro to replace list of special characters

    A M A Z I N G ! !
    That seems to have hit the spot! Well done, ever so thankful.

    If I need to add any in a live example would be ę (that I appear to have missed) can add that anywhere? e.g.

    Dim v As Variant, i As Long
    v = Array("ę", "ø", "o", "Š", "S"

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Find and Replace Macro to replace list of special characters

    Quote Originally Posted by dcowiesmith View Post
    If I need to add any in a live example would be ę (that I appear to have missed)
    Here is another macro that you can try which I have also set up to replace that ę character with an e...
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,815

    Re: Find and Replace Macro to replace list of special characters

    You are very welcome.
    Yes, you can add or delete characters as needed as long as you follow the pattern, that is: first the letter to find followed by its replacement.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help to create a macro - Find special characters and replace
    By Brad010140 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2017, 12:41 PM
  2. Find & Replace all special characters with regular
    By mike_vr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2017, 04:23 AM
  3. find and replace special characters
    By irfanparbatani in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2015, 09:30 PM
  4. [SOLVED] Macro to replace special characters, keep list of replacements or confirm before replacing
    By mattyfaz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-14-2015, 09:31 PM
  5. [SOLVED] Find and replace special characters (unicode)
    By joevan1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-10-2013, 06:05 AM
  6. Replies: 1
    Last Post: 05-25-2006, 11:29 AM
  7. How do I find replace special characters?
    By zzapper in forum Excel General
    Replies: 1
    Last Post: 06-27-2005, 02:05 PM

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