Split string based on matching

gripper

Board Regular
Joined
Oct 29, 2002
Messages
143
I have a spreadsheet with addresses. They are formatted poorly and I am trying to clean them up.

What I want to do is split the text string and add in a space and comma. The split will be based on the value of another cell

For instance in Column C I have data that looks like this:

123 North MichiganManton, MI 49663
456 E. Main StMarthasville, MO 63357
758 ThayerButte, NE 68722

In column D I have the cities listed as such

Manton
Marthasville
Butte

What I would like to do is either in its existing Column C or another column copy the data but with the name of the city in Column D find that match in column C and add a ", " (comma and space) in front of the city name within this string. This will clean up the data and make it usable.

So the outcome when finished would be;

123 North Michigan, Manton, MI 49663
456 E. Main St, Marthasville, MO 63357
758 Thayer, Butte, NE 68722

Your thoughts would be greatly appreciated.

Thank you
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,488
Office Version
  1. 365
Platform
  1. Windows
Using the SUBSTITUTE formula should do what you want.
In another column, for row 1, the formula would look like:
Code:
=SUBSTITUTE(C1,D1,", " &D1)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,378
Messages
5,528,341
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top