+ Reply to Thread
Results 1 to 6 of 6

Remove exact match only

  1. #1
    Registered User
    Join Date
    09-16-2014
    Location
    Weymouth, Dorset
    MS-Off Ver
    2010
    Posts
    4

    Remove exact match only

    Hi all

    I am sure this has probably been asked before, but I have done a search and can't see anything that matches.

    I am currently working with a database which includes addresses. These addresses include the "area" in one of the cells, but I would like to remove all references to the area from the data. Unfortunately, the "area" could be in any of the address lines (so Address1, Address2, Address3, etc).

    I am using this syntax -

    Cells.Replace What:="Northway", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False


    (Northway is an example, not a real area - there are about 50-60 different areas that I need to remove).

    For instance, an address could be 1 The Avenue, Northway, Mytown - where "Northway" is the area and is in Address2. Or it could be Flat 1, 1 The Avenue, Northtway, Mytown, where Northway is in Address3. However, that's straightforward enough. My problem comes when I have an address such as 1 Northway Avenue, Southway, Mytown. I have already established that Northway is an area and so should be removed, but as it is also part of the string in Address1, it's also getting removed from there as well; changing the data to read 1 Avenue, Southway, Mytown.

    I hope this explains the issue - I'm not terribly proficient in VBA so would be grateful for any advice, thoughts or ideas, or to be pointed to any previous similar questions.

    Many thanks

    Ed

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Remove exact match only

    The trouble you're going to have is that without any proper data governance you're essentially going to have to write a rule for every possible scenario.

    I think you're also going to have to scan through each field character by character so you can put in functions to test if, for example, the matching value has a number 2 characters before it in the field, ie it's a street address.

    Question: In your fields, are all address components always separated by a comma? If so, you can look for commas.....

    Have a read of: https://www.techonthenet.com/excel/formulas/mid.php

  3. #3
    Registered User
    Join Date
    09-16-2014
    Location
    Weymouth, Dorset
    MS-Off Ver
    2010
    Posts
    4

    Re: Remove exact match only

    Thank you for the reply which sort of confirms my worst fears. Unfortunately, the data is exceptionally poor quality - it's been entered in numerous different ways by any number of different users and there is no way of really separating each aspect of the address - commas would have been nice, but they are a rare commodity and highly prized in this office...you'd almost think that the company had bought keyboards without them! In practice, this means that I will need to sift through the cells manually anyway, it would just have been nice to automate a little bit of the process.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Remove exact match only

    I have not read the text description, but as per the header, if you want to an exact match.

    Change this line

    xlPart

    INTO

    xlWhole

  5. #5
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Remove exact match only

    I still think looking for a number 2 chars before the start of the matching section of the field would filter out street names that match area names.

  6. #6
    Registered User
    Join Date
    09-16-2014
    Location
    Weymouth, Dorset
    MS-Off Ver
    2010
    Posts
    4

    Re: Remove exact match only

    Amazing - exactly what I wanted...so simple too!! Thank you so much!!

+ 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. To Sort exact and partial exact match for a single column.
    By Jagdev in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2014, 05:08 AM
  2. [SOLVED] sumif which finds text, not an exact match, but a close match instead
    By Beefy1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-19-2014, 08:29 PM
  3. Replies: 3
    Last Post: 06-17-2013, 12:37 PM
  4. Replies: 4
    Last Post: 02-19-2013, 02:19 PM
  5. [SOLVED] Index & Match returning incorrect value. Arrays fixed and exact match used.
    By SDes in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-07-2012, 08:29 PM
  6. Replies: 6
    Last Post: 01-28-2012, 06:59 PM
  7. Replies: 2
    Last Post: 01-28-2012, 05:26 PM

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