Основанный на превосходном коде cellyson'а, вот, надеюсь, довольно закаленный макрос, который я сделал для себя.Работает в Excel 2016 (и нет причин, по которым он не должен работать в предыдущих версиях).
Option Explicit
Sub FastReplace(Optional CalculateAfterReplace As Boolean = True)
Dim SelectedRange As Range
Dim What As String, Replacement As String
'Let's set the 3 input data in place, and allow the user to exit if he hits cancel (or if he wants to look for an emprty string)
Set SelectedRange = Selection
What = InputBox("This macro will work on the EXISTING selection, so please cancel and restart it if you haven't selected the desired range." _
& vbCrLf & vbCrLf & "The selection is " & SelectedRange.Address(ReferenceStyle:=xlA1, RowAbsolute:=False, ColumnAbsolute:=False) _
& vbCrLf & vbCrLf & "What is the text that needs to be replaced?", "Fast replace stage 1 of 2")
If What = "" Then Exit Sub
Replacement = InputBox("You chose to look for " _
& vbCrLf & vbCrLf & """" & What & """" _
& vbCrLf & vbCrLf & "Now, what is the replacement text?", "Fast replace stage 2 of 2")
If StrPtr(Replacement) = 0 Then Exit Sub 'We want to allow an empty string for replacement, hence this StrPtr trick, source https://stackoverflow.com/questions/26264814/how-to-detect-if-user-select-cancel-inputbox-vba-excel
Dim StoreCalculation As Integer
On Error GoTo FastReplace_error 'So that we're not stuck due to the ScreenUpdating = False in case of an error
Application.EnableEvents = False
Application.ScreenUpdating = False
StoreCalculation = Application.Calculation
Application.Calculation = xlCalculationManual
'Let's log what we're doing in the debug window, just in case
Debug.Print "Working on " & SelectedRange.Address(ReferenceStyle:=xlA1, RowAbsolute:=False, ColumnAbsolute:=False)
Debug.Print "Replacing """ & What & """ for """ & Replacement & """."
Debug.Print "CalculateAfterReplace = " & CalculateAfterReplace
'The heart of this sub
SelectedRange.Replace What:=What, Replacement:=Replacement, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
'Wrapping up
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = StoreCalculation
If CalculateAfterReplace Then Application.CalculateFull
Beep
Exit Sub
FastReplace_error:
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = StoreCalculation
If CalculateAfterReplace Then Application.CalculateFull
Err.Raise Err.Number, Err.Source, Err.Description
End Sub