Help with creating a macro...

MyHero

New Member
Joined
Jan 22, 2009
Messages
26
I have a list of items in column A. I need to replace all the occurances of the word tor1 with the value in b1. The value in B1 changes frequently.

Could someone help me write a macro that would accomplish this?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the Board!

This one can be recorded using Find & Replace, then just replace the Replacement:="Sometext" with Replacement:=Range("B1").

Code:
    Range([A1], Cells(Rows.Count, "A").End(xlDown)).Replace What:="tor1", Replacement:=Range("B1").Value, LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

Hope that helps,
 
Upvote 0
Welcome to the Board!

This one can be recorded using Find & Replace, then just replace the Replacement:="Sometext" with Replacement:=Range("B1").

Code:
    Range([A1], Cells(Rows.Count, "A").End(xlDown)).Replace What:="tor1", Replacement:=Range("B1").Value, LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
Hope that helps,

Thanks a lot Smitty, you guys are incredible. My friends ask me for excel help, but when I need help, this is where I go! :D
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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