简体   繁体   中英

how to replace special character using excel vba

Am having this " " special character in my excel work book, i want to replace all with ".", when i place this character in the code , it turns to "?" after i run the macro it replaces everything to "."

Sub FindReplaceAll()

 Dim ws      As Worksheet
 For Each ws In ActiveWorkbook.Worksheets
   ws.Cells.Replace What:="�", Replacement:=".", LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

       Next ws
End Sub

Thanks in advance

Try to copy this character in a cell, then have the ASCII number and replace the character by the ASCII num:

Dim num =123
Ex:
    Cells.Replace What:=Chr(Num), Replacement:=".", LookAt:= _
        xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM