Sub PiLiangChaZhaoTiHuan()
On Error Resume Next
Dim arr, MoShi, i, s
arr = Application.InputBox("选择查找与替换的数据源", "批量查找替换", Selection, , , , , 8)
MoShi = Application.InputBox("批量替换选择区域填1" & vbCrLf & "批量替换当前工作表填2" & vbCrLf & "批量替换全部工作表填3", "批量查找替换", 1)
If MoShi = 1 Then
Set QuYu = Application.InputBox("选择查找区域", "批量查找替换", Selection, , , , , 8)
For i = 1 To UBound(arr)
QuYu.Replace What:=arr(i, 1), Replacement:=arr(i, 2), LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Next
End If
If MoShi = 2 Then
For i = 1 To UBound(arr)
ActiveSheet.UsedRange.Replace What:=arr(i, 1), Replacement:=arr(i, 2), LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Next
End If
If MoShi = 3 Then
For i = 1 To UBound(arr)
For s = 1 To Sheets.Count
Sheets(s).UsedRange.Replace What:=arr(i, 1), Replacement:=arr(i, 2), LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False, SearchFormat:=True, ReplaceFormat:=True
Next
Next
End If
End Sub