使用宏可以实现,如下:
Sub 宏1()
Dim c1, c2, c3, t1, t2, t3
c1 = 1 '查找值1
c2 = 2 '查找值2
c3 = 3 '查找值3
t1 = 2 '对应值1的替换值
t2 = 3 '对应值2的替换值
t3 = 1 '对应值3的替换值
'先把123分别换成abc
With Selection.Find
.Text = c1
.Replacement.Text = "a"
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = c2
.Replacement.Text = "b"
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = c3
.Replacement.Text = "c"
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
'再把abc分别换成231
With Selection.Find
.Text = "a"
.Replacement.Text = t1
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "b"
.Replacement.Text = t2
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "c"
.Replacement.Text = t3
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub 宏1()
Dim c1, c2, c3, t1, t2, t3
c1 = 1 '查找值1
c2 = 2 '查找值2
c3 = 3 '查找值3
t1 = 2 '对应值1的替换值
t2 = 3 '对应值2的替换值
t3 = 1 '对应值3的替换值
'先把123分别换成abc
With Selection.Find
.Text = c1
.Replacement.Text = "a"
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = c2
.Replacement.Text = "b"
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = c3
.Replacement.Text = "c"
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
'再把abc分别换成231
With Selection.Find
.Text = "a"
.Replacement.Text = t1
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "b"
.Replacement.Text = t2
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "c"
.Replacement.Text = t3
.Wrap = wdReplaceOne
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub