这个宏应该清理一些特殊字符。当我运行它时,它会消除一切。我只用一列" B"开始测试。 请你帮忙搞清楚错误在哪里? 我在正则表达式上发布了类似的问题,因此这可能是我尝试实现的程序方法,即标准化数据以将所有这些导出到SQL数据库。 请注意,这个宏主要清理用户输入的数据。
再次感谢您的意见/答案/建议。
Sub CaracteresEspeciales()
'Esta macro es una version extendida que toma caracteres predefinidos de una lista
MsgBox "Esta macro encuentra caracteres especiales más usados, se tomará unos breves instantes"
Worksheets("Candidatos").Activate
Application.ScreenUpdating = False
Dim asterisco As String
Dim coma As String
Dim punto As String
Dim dospuntos As String
Dim puntoycoma As String
Dim slash As String
Dim backslash As String
Dim chevron As String
Dim apostrofe As String
Dim leftparenthesis As String
Dim righparenthesis As String
Dim porcentaje As String
Dim ampersand As String
Dim dollarsign As String
Dim leftquestionmark As String
Dim rightquestionmark As String
Dim leftexclamationmark As String
Dim rightexclamationmark As String
Dim backtilde As String
Dim tilde As String
Dim arroba As String
Dim espacio As String
asterisco = "*"
coma = ","
punto = "."
dospuntos = ":"
puntoycoma = ";"
slash = "/"
backslash = "\"
chevron = "`"
apostrofe = "'"
leftparenthesis = "("
rightparenthesis = ")"
porcentaje = "%"
ampersand = "&"
dollarsign = "$"
leftquestionmark = "¿"
rightquestionmark = "?"
leftexclamationmark = "¡"
rightexclamationmark = "!"
backtilde = "`"
tilde = "´"
arroba = "@"
espacio = " "
Worksheets("Candidatos").Activate
Columns("B:B").Replace What:=coma, replacement:=espacio
Columns("B:B").Replace What:=punto, replacement:=espacio
Columns("B:B").Replace What:=dospuntos, replacement:=espacio
Columns("B:B").Replace What:=puntoycoma, replacement:=espacio
Columns("B:B").Replace What:=slash, replacement:=espacio
Columns("B:B").Replace What:=backslash, replacement:=espacio
Columns("B:B").Replace What:=chevron, replacement:=espacio
Columns("B:B").Replace What:=apostrofe, replacement:=espacio
Columns("B:B").Replace What:=leftparenthesis, replacement:=espacio
Columns("B:B").Replace What:=righparenthesis, replacement:=espacio
Columns("B:B").Replace What:=porcentaje, replacement:=espacio
Columns("B:B").Replace What:=ampersand, replacement:=espacio
Columns("B:B").Replace What:=dollarsign, replacement:=espacio
Columns("B:B").Replace What:=leftquestionmark, replacement:=espacio
Columns("B:B").Replace What:=rightquestionmark, replacement:=espacio
Columns("B:B").Replace What:=leftexclamationmark, replacement:=espacio
Columns("B:B").Replace What:=rightexclamationmark, replacement:=espacio
Columns("B:B").Replace What:=backtilde, replacement:=espacio
Columns("B:B").Replace What:=tilde, replacement:=espacio
Columns("B:B").Replace What:=arroba, replacement:=espacio
Application.ScreenUpdating = True
'what type of data (in spanish)
'personales (b,c,k) personal data
'laborales (q, u ,z), (ab, af, ak) ,( am, aq, av) , (ax,bb,bg) work desc.
'estudiantiles (bi,bj),(bq,br),(by,bz),(cg,ch) academic info.
MsgBox "Gracias por la espera, se han limpiado datos personales"
End Sub
答案 0 :(得分:2)
使用此方法,您的问题与外卡有关。 *
和?
都是外卡,可以匹配单个字符,也可以匹配所有字符。
要将其解释为文字,请将What
字符串更改为~*
和~?
asterisco = "~*"
rightquestionmark = "~?"
如果您还要将~
作为要替换的字符(我没有看到它),则应将其输入为~~