+ Reply to Thread
Results 1 to 2 of 2

Macro for search and replace function

  1. #1
    Registered User
    Join Date
    02-10-2017
    Location
    usa
    MS-Off Ver
    8
    Posts
    3

    Question Macro for search and replace function

    Hi, I am looking for a macro solution to multiple search and replaces.

    I have two columns of region names

    column 1 ------------------------------------------------------ column 2

    New York New York ---------------------------------------- New York-Jersey City-White Plains
    SAN FRANSISCO SAN FRANSISCO COUNTY ------------ San Francisco-Redwood City-South San Francisco
    IRVING DALLAS -------------------------------------------- Dallas-Plano-Irving

    I need these names to be the same. What I would like to do is to search column one for values in column 2, and then replace the entire content of cells in column one with the entire content of cells in column two. For example: search column one for any cell that contains New York, Jersey City, or White Plains, and then replace the entire content of the column 1 cell with New York-Jersey City-White Plains. Then move on to the row below. I know this can be done for simple search and replace. What makes it harder is that I don't want to do a simple find a replace. I am hoping that there is some kind of "or" function in macros that lets you search for New York OR Jersey City OR White Plains based on just the one cell, and then replace the entire contents of the cell that has those values. Any solutions would be welcomed.

    ****Another problem is that city names appear in different states, for example Manhattan ny and Manhattan Kansas. I also have columns of states next to each column 1 and column two. If there is anyway to qualify the search and replace so that it only search for values when the states match, that would be very helpful. However, this is less important to me right now.

    Thank you. Will

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Macro for search and replace function

    My best guess is that you post a sample file to get some more response.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. looking for a macro to search and replace within rows and the do the same in the next row
    By johnjones1962 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2013, 08:55 PM
  2. [SOLVED] Search and replace function
    By Kris@home in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-19-2012, 10:00 AM
  3. search & replace macro
    By LiamF in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-04-2010, 02:41 PM
  4. Macro Search+Replace Error
    By DoodleExcel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2010, 12:21 PM
  5. function to search and replace
    By sithel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-20-2008, 11:34 AM
  6. Search and Replace macro
    By delnaja in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-25-2008, 06:16 AM
  7. Search and replace macro
    By timecop in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2007, 08:06 AM
  8. Search and replace macro?
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2005, 09:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1