VBA to Find and Replace Text from a cell

borkarrr

New Member
Joined
May 23, 2015
Messages
44
Hello friends i have a sheet as below-

In Sheet 1

Column A Column B
Company Name Example Inc.
Games Football and Swimming

In Sheet 2
I have a sheet having thousands of sentences in Column A
Eg- ABC Inc is a very big company. ABC Inc hires many employees who while their time away playing games in office...

What i want to Do-

Replace - " ABC Inc" by "Example" Inc
Replace - "Games" - by the "Football and Swimming"

So the sentence should look like this after using the macro
Example Inc is a very big company. Example Inc hires many employees who while their time away playing Football and Swimming in office...


Might as well - just use find and replace function??-

Yes i would- but find and replace function needs me to actually type the stuff i want to find and replace

i have just given an example above
-in reality there are many parameters (like 25-30?) that i need to change besides company name and the games they play

is there any way (by VBA) i could get the contents which are in green cell to somehow magically get themselves typed into find and replace function

Thanks in advance
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
How about
Code:
Sub ReplaceLst()
   Dim Ary As Variant
   Dim i As Long
   
   With Sheets("Sheet1")
      Ary = .Range("A2", .Range("B" & Rows.count).End(xlUp))
   End With
   With Sheets("Sheet2")
      For i = 1 To UBound(Ary)
         .Range("A:A").Replace Ary(i, 1), Ary(i, 2), xlPart, , False, , False, False
      Next i
   End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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