Find and replace multiple values at once in Excel using VBA

preview_player
Показать описание
The video is a short tutorial on how to find and replace multiple values at once in Excel using VBA.
Рекомендации по теме
Комментарии
Автор

Thanks a lot! Worked perfectly for me. Was trying to find a solution for more than an hour, and this one worked for me.

parasshah
Автор

Here, I typed it out for you:

Sub MultiFindNReplaceNew()
Dim Rng As Range

Dim InputRng As Range, ReplaceRng As Range
xTitleId = "MultiReplace"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Data Range to Process", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = to Make:", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Application.ScreenUpdating = True
End Sub

To use:
1) Tools > Macros > Visual Basic Editor
2) Insert > Module
3) Paste code above. I changed a couple of the labels for clarity. The function is exactly the same as the video.
4) Run
5) Select the data range that you want to run the find and replace on. Press Ok.
6) Select the range with the replacements to make. This should be two columns wide. Strings to find in the left column and their corresponding replacements in the right column.

Worked beautifully for me on a data set of 1 column X 25, 000 rows.

hau
Автор

thanks you very much dear its very help full for me i bless from god that he gave you good deeeds.

gulamvaseem
Автор

Hi Mr. Smith, What could I add to this code to make it stop after the first set of values has been replaced?

matthewnewsome
Автор

what if i need to replace matching the full content of the cell???

BetsyCohenArg
Автор

That helps me a lot for my work. Thank you very much.

khmermovies
Автор

got a run-time error '13':type mismatch.I'm working with numbers only.

kurtturner
Автор

Kindly advise macro to find and replace in entire worksheet

varunnarain
Автор

I want to change a phrase to another phrase, in many excel files in 1 folder at the same time, how to do with VBA excel?

anhnhatnguyet
Автор

A little bit of explanatory text in the macro would have been most welcome.

twig
Автор

so where is the code? I thought you would share it as part of this tutorial - Thank you

AriahSV
Автор

Works great if you don't mind spending the rest of the day correcting all the mistakes in your Excel sheet. Sad trombone!

andytownman
Автор

Sub MultiFindNReplaceNew()
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "Test"
Set InputRng = Application.Selection
Set InputRng = Range ", xTitleId, InputRng.Address, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Application.ScreenUpdating = True
End Sub

noahholowatch