VBA to replace multiple values

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all

I hope you can help on this please

In worksheet called "Sheet1" I have in column "A" 100 text values
In Column "B" 1 have the text that I want to use to replace in each value

In worksheet "Data" in column "K" this is where I want to replace the values

Just like replace: Find What column "A1": Replace with "B1" but place the result in "Data" worksheet column "K" where there is a match.

Is this possible please
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How about
Code:
Sub VbaHell()
   Dim ary As Variant
   Dim i As Long
   
   With Sheets("Sheet1")
      ary = Range("A1", Range("A" & Rows.Count).End(xlUp).Offset(, 1)).Value2
   End With
   With Sheets("Data")
      For i = 1 To UBound(ary)
         .Range("K1", .Range("K" & Rows.Count).End(xlUp)).Replace ary(i, 1), ary(i, 2), xlWhole, , False, , False, False
      Next i
   End With
End Sub
 
Upvote 0
Fluff this works great and saves me do much time
thanks very much for your help
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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