word中怎么批量更改数字
我word文档里又很多数字为456、457、458、等等,怎么编写个宏或者替换方法,变成1、2、用宏应该可以,但是必须针对是带“、”号的数字,怎么写就不会了。那位大神指导...
我word文档里又很多数字为456、 457、 458、等等,怎么编写个宏或者替换方法,变成1、 2、 用宏应该可以,但是必须针对是带“、”号的数字,怎么写就不会了。那位大神指导下,谢谢
用的其他地方找到,带、数字也改了。不带、的数字也一起改了。
Sub shux()
Dim Rng As Range, Shu As Double
Set Rng = ActiveDocument.Content
With Rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
Do While .Execute(findtext:="[0-9.-]{1,}") '包括小数和负数
MsgBox Rng
If VBA.IsNumeric(Rng) Then
Shu = Replace(Rng, Rng, Rng + 15) '原值加15
Rng = Shu
End If
Rng.SetRange Rng.End, ActiveDocument.Content.End
Loop
End With
End Sub 展开
用的其他地方找到,带、数字也改了。不带、的数字也一起改了。
Sub shux()
Dim Rng As Range, Shu As Double
Set Rng = ActiveDocument.Content
With Rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
Do While .Execute(findtext:="[0-9.-]{1,}") '包括小数和负数
MsgBox Rng
If VBA.IsNumeric(Rng) Then
Shu = Replace(Rng, Rng, Rng + 15) '原值加15
Rng = Shu
End If
Rng.SetRange Rng.End, ActiveDocument.Content.End
Loop
End With
End Sub 展开
2个回答
展开全部
Sub shux()
Dim Rng As Range, Shu As Double
Set Rng = ActiveDocument.Content
With Rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
Do While .Execute(findtext:="[0-9.-]{1,}、") '包括小数和负数
'MsgBox Rng
Rng = Left(Rng, Len(Rng) - 1)
If VBA.IsNumeric(Rng) Then
Shu = Replace(Rng, Rng, Rng - 455) '原值减455
Rng = Shu & "、"
End If
Rng.SetRange Rng.End, ActiveDocument.Content.End
Loop
End With
End Sub
Dim Rng As Range, Shu As Double
Set Rng = ActiveDocument.Content
With Rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
Do While .Execute(findtext:="[0-9.-]{1,}、") '包括小数和负数
'MsgBox Rng
Rng = Left(Rng, Len(Rng) - 1)
If VBA.IsNumeric(Rng) Then
Shu = Replace(Rng, Rng, Rng - 455) '原值减455
Rng = Shu & "、"
End If
Rng.SetRange Rng.End, ActiveDocument.Content.End
Loop
End With
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询