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
124
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>
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Watch MrExcel Video

Forum statistics

Threads
1,122,822
Messages
5,598,304
Members
414,224
Latest member
Crazy_FC

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