llgd.net
当前位置:首页 >> ExCEl vBA 删除特殊字符 >>

ExCEl vBA 删除特殊字符

Sub 去除特殊字符() Dim n, txArr, tx_s, tx_Asc, s, c, new_s n = 100 '处理的最大行数,可更改 tx_s = "#,*,%,&" '特殊字符,可增加 txArr = Split(tx_s, ",") tx_Asc = "," For i = 0 To UBound(txArr) tx_Asc = tx_Asc & Asc(txArr(i)) & ",...

你最好吧特殊字符放在一个字符串里,我可以试试为你写一个 Const sList = "[]{}【】()()", sRange = "B5:P10"Sub Arrange() Dim aRr Dim i As Integer, j As String Dim rT, rC As Range Set rT = Sheets(1).Range(sRange) ReDim aRr(1 To Len...

Sub s() arr = Array("[", "]", ",", "{", "}", ",", "【", "】", ",", "(", ")", ",", "(", ")") t = [e25] For i = 0 To UBound(arr) t = Replace(t, arr(i), "") Next [e25] = tEnd Sub

这种生僻字的区位码估计会靠后,你把所有要删除的发上来看看,或者上个图片,取汉字的区位码,然后判断就简单一点 传个照片或者文档,我查一下区位码有没有规律

Sub s() Dim arr, i%, t%, c As Range arr = Array("#", "%", "&", "$", "^") For Each c In [c51:f55] For i = 0 To UBound(arr) t = InStr(c.Text, arr(i)) If t > 0 Then c = Mid(c.Text, t) Exit For End If Next NextEnd Sub

这个确实是只删除右侧的两个字符。 我不知道为啥你运行会删了前和后的。。。。 想要删除左侧两个字符,第三行改成 c.Value = Right(c.Value, Len(c.Value) - 2)两边都删就是 c.Value = Mid( c.Value, 2, Len(c.Value) - 4)

sub test()myrow=Range("A65536").End(xlUp).Rowfor i=myrow to 1 step -1 if range("A" & myrow )="X" then Range("A" & i & ":A" & myrow).ClearContents end ifnextend sub

Sub aa()For Each c In Selectionc.Value = Left(c.Value, Len(c.Value) - 2)NextEnd Sub 鼠标选中需要修改的数据区域,运行宏aa

Sub 删除字符()arr = [c2:h20]Set regex = CreateObject("VBScript.RegExp")regex.Global = Trueregex.Pattern = "[,。@#$%&]+"For i = 1 To UBound(arr) For j = 1 To UBound(arr, 2) arr(i, j) = regex.Replace(arr(i, j), "/") NextNext[c2:...

不用VBA只用公式也可以。 如原数据在B8,在C8输入公式:=MID(B8,3,100) 下拉填充。 好吧,既然你非要vba,你可以这样改: 选中后,只删除前面两个字符 Sub aa()For Each c In Selectionc.Value = Right(c.Value, Len(c.Value) - 2)NextEnd Sub ...

网站首页 | 网站地图
All rights reserved Powered by www.llgd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com