Mass replace and match entire cell

MossJFoley

New Member
Joined
May 21, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Helo,

I have several exports from software which didn't tie information in together. So I have a list of parts that have all their descriptions, another that has all their dimensions and another that has their manufacturer. Only the list with the descriptions is complete.

I have used the mass replace by range below on previous projects but I want to modify it so that it matches the entire cell. Some of the parts listed are close and very few are the same length so part "1234" which is a diode gets confused with "1234-5" which is a "solenoid" and when I use the below code I get "diode-5"

Sub MutliFindNRepllaceNew()
Dim RNG As Range
Dim Inputrng As Range, ReplaceRng As Range
xTitleID = "Test"
Set InputRng = Application.Selection
Set InputRng = Application.inputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", 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
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Welcome to the Board!

If you want it to match the ENTIRE contents only, add that argument to your REPLACE code, i.e.
Rich (BB code):
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0,1).Value, LookAt:=xlWhole

There is a trick if you don't know what all these arguments are, you can turn on your Macro Recoder and record yourself manually doing exactly what you want.
Then, stop the Macro Recorder, view the code you just recorded, and pick off the pieces that you need.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top