Macro to search a column and if a cell contains a word replace that cell with that word

John T

Board Regular
Joined
Nov 28, 2013
Messages
145
Office Version
  1. 365
Platform
  1. Windows
I have data in column 'A' with lots of models of cars that i need shortening to just display the model.


An example of the data i have is as follows:

Make/model
Yaris TSpirit 5dr 1.33 VVT-i M
Prius T3 5dr 1.8 VVT-i Hybrid
Yaris T2 5dr 1.0 VVT-i Man
Yaris 1.3 GLS (CDX) Auto 5dr
AYGO Fire 5dr 1.0 VVT-i Man AC
Avensis T3-X Tourer 2.2 D-4D M
Prius T Spirit 5dr 1.8 VVT-i H
Verso TR 2.0 D-4D Man
Avensis T2 5dr 1.8 VVT-i Man
Auris 5Dr Hat 1.6 Sr Manual
Avensis T3-S 5dr 1.8 VVT-i Seq
Yaris Verso 1.3 A Premium
Avensis T3S 5dr 1.8 A
Land Cruiser Invincible 5dr 3.

<tbody>
</tbody>

I need a macro to search column A and if a cell contains the word Yaris (for example) to replace that cells contents with Yaris, if not i need it to then search for the next model, Prius for example, and replace the contents of that cell with that model.

If a cell doesn't contain one of the lookup words i need it to leave that cell as it is.

I need the above data to look like this after the macro.

Make/model
Yaris
Prius
Yaris
Yaris
Aygo
Avensis
Prius
Verso
Avensis
Auris
Avensis
Yaris
Avensis
Land Cruiser

<tbody>
</tbody>
 

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.

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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