Find and Replace a specific area of a cell

blane

New Member
Joined
Sep 29, 2006
Messages
2
Hello.

I'm trying to create a macro that runs a find and replace within a column in my spreadsheet...

I'm hoping to use Excel to go through column "A", find all the words "THE" and replace them with "The"... BUT - here's the snag:

The column contains book titles and I only want to change "THE" when it happens to be the first word in the cell.

For example:

"THE LUFTWAFFE IN THE WEST 10-20 MAY 1940"

Due to the way I want to display this in another program, I want to replace the first "THE" with "The".. but not the "THE" found later in the title.

If anyone could come up with a solution to this problem it would be much appreciated and save me a lot of time. :cool:

Thank you.

-Blane
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
Hi, blane, welcome to the board

I know you asked for a macro but you could also use a formula approach quite easily...

put this formula in B1 and fill down

=IF(LEFT(A1,4)="the ",REPLACE(A1,1,3,"The"),A1)

Select column B, copy, edit > paste special > values
Delete column A
 

Forum statistics

Threads
1,141,023
Messages
5,703,797
Members
421,318
Latest member
cg_cartoonexcel

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
Top