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

ExCEl vBA 删除特殊字符

答: Sub Demo() Dim LR As Long LR = Cells(Cells.Rows.Count, 1).End(xlUp).Row With CreateObject("VBSCRIPT.REGEXP") .Pattern = "\*.+\*" For i = 1 To LR Cells(i, 1) = .Replace(Cells(i, 1), "") Next End WithEnd 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

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)) & ",...

楼上说的替换更简单,一定需要VBA的话,代码如下: Option ExplicitSub 宏1() Dim arr, i, n, x n = Range("f1").End(xlDown).Row arr = Range("f1").Resize(n, 1) For i = 1 To n x = InStr(arr(i, 1), "组") If x > 0 Then arr(i, 1) = Left(a...

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

你最好吧特殊字符放在一个字符串里,我可以试试为你写一个 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 aa()For Each c In Selectionc.Value = Left(c.Value, Len(c.Value) - 2)NextEnd Sub 鼠标选中需要修改的数据区域,运行宏aa

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

Sub xxx() Dim rng As Range Set regex = CreateObject("VBSCRIPT.REGEXP") '正则表达式 For Each rng In Range("i4:n17") '范围 With regex .Global = True .Pattern = "\d+" n = .Execute(rng.Value).Count - 1 If .test(rng.Value) = True Th...

Sub xx() For i = 5 To 14 With Cells(i, 1) t = Cells(i, 1) For j = Len(t) To 1 Step -1 If .Characters(j, 1).Font.ColorIndex = 3 Then t = Left(t, j - 1) & Replace(t, Mid(t, j, 1), "", j, 1) End If Next End With Cells(i, 1) = t Ne...

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