rwhn.net
当前位置:首页 >> ExCEl vBA特定字符替换 >>

ExCEl vBA特定字符替换

这个最简单了 用Replace语句: 例如: Dim s as String s = "axyzx" s = Replace(s,"x","abc") Msgbox s 那么这个时候就得到了:aabcyzabc

Sub xxx() Dim c For Each c In Range("c4:g9").Cells c = Replace(c, "ADFGS", "ZXG") Next cEnd Sub

Sub 宏1() a = "abcd" b = "hijk" Cells.Replace What:=a, Replacement:=b, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=FalseEnd Suba是被替换的内容 b是替换上的内容

打开VBA,工具-引用-Microsoft VBScript Regular Expressions Function StrReplace(s As String, p As String, r As String) As String Dim re As RegExp Set re = New RegExp re.IgnoreCase = True re.Global = True re.Pattern = p StrReplace...

VBA 中可以使用 这两个函数 函数碍… 也可以直接使用 另外一种 Like 函数…… 如: If A Like "*aa*" Then MsgBox "A中有aa 这个字符串" Else MsgBox "A中没有aa 这个字符串" End If 或者 使用 InStr 这个函数计算 也可以……

可以这么写: Dim LResult As String LResult = Replace("alphabet", "a", "e") 把字母a换成e

Sub 替换() arr = Array("ABC,BCA,CCAB") brr = Replace(arr(0), "C", "Y") 'C被Y替换 End Sub

Sub 替换() Dim a, b, c As Integer c = 7 '第7行 For a = 1 To 4 '共计4行数据 For b = 3 To 5 '每行3个数据 If ActiveSheet.Cells(c, b) = "0123456789" Then ActiveSheet.Cells(c, b) = "ABCDEFGHIJ" '替换数据 End If Next b c = c + 1 '+1...

一张图片解决你所有问题,细看 Function 替换(检测内容) As String Dim regx As Object '后期绑定 Set regx = CreateObject("VBScript.RegExp") '后期绑定 Dim mat As Object Dim m As Object Dim 返回内容 As String Set regx = New RegExp Wit...

当然可以,我以前写的,你可以参考一下: Private Sub CommandButton1_Click() On Error Resume Next Dim iRow As Integer, myPath As String Dim wdApp As Word.Application, wdDoc As Word.Document, wdRange As Word.Range Dim 收文日期 As S...

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