+ Reply to Thread
Results 1 to 6 of 6

Search for data at the end of the string?

  1. #1
    Registered User
    Join Date
    07-02-2012
    Location
    Usa
    MS-Off Ver
    Office 365
    Posts
    15

    Search for data at the end of the string?

    I am working on a long list of addresses. Almost all of the addresses have have the city at the end (like "1234 Main Street CITY"). I am wanting to remove the CITY from the address field for a vlookup that we do. There are two problems to this.
    1. CITY isn't always fully spelled out (sometimes it's CI, or CIT)
    and 2. Some of the street names contain the CITY word (so like 1234 CITY Street CITY) so a search and replace won't work.
    The only thing they have in common is they are at the end of the text.

    So... is there a way to search for data with nothing after it? I tried looking it up and the only thing I could find was the TEXTAFTER function, but that doesn't look like it will do what I need.
    I am hoping there is a symbol I an use so I can do a find a replace for like CITY% and it will only remove the ones at the end.

    Thank you.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,843

    Re: Search for data at the end of the string?

    What version of excel- you say 2016 - then a function that TEXTAFTER - not available in 2016 - so you must have a later version, please update profile , so we know what version we are providing a solution


    The forum does allow for spreadsheets to be uploaded direct to the forum -

    Please see the Yellow Banner at the top of the page explaining how to attach a sample spreadsheet

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.

    Here are the instructions, found at the top of the page again
    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results. For a new thread (1st post), scroll to Manage Attachments, otherwise scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    07-02-2012
    Location
    Usa
    MS-Off Ver
    Office 365
    Posts
    15

    Re: Search for data at the end of the string?

    Ok, I have updated my Office in my profile (it's been a while since I've been here). I also attached an example file with two columns. Column A is how the addresses are in my excel file and Column B is how I need them to look.
    As you can see in column A, the city is "Buford" however, I can't just do a Find and Replace for that because there are roads named Buford as well. So I am wanting to know if it is possible to do a Find and Replace for "Buford" and tell it to only replace it if there is nothing after it (meaning it is at the end of the string).
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,525

    Re: Search for data at the end of the string?

    How about this in B2? Remove ALL expected results before adding.

    =TEXTBEFORE(A2:A15," ",-1)
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    07-02-2012
    Location
    Usa
    MS-Off Ver
    Office 365
    Posts
    15

    Re: Search for data at the end of the string?

    That does seem to work. Thank you.
    Last edited by AliGW; 06-18-2024 at 10:01 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,525

    Re: Search for data at the end of the string?

    You're welcome.

+ 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. [SOLVED] Search String then add data next to it.
    By Johnny0811 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-09-2022, 11:26 AM
  2. string search and data modificatoin
    By lotsa? in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2018, 09:24 AM
  3. Replies: 2
    Last Post: 01-02-2013, 08:35 AM
  4. [SOLVED] Search for string across header row, then search for another string down found column
    By TucsonJack in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2012, 02:09 PM
  5. Search for word in a string of data
    By Cydney in forum Excel General
    Replies: 2
    Last Post: 02-11-2009, 11:58 AM
  6. [SOLVED] to search for a string and affect data if it finds the string?
    By Shwaman in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2006, 09:00 PM
  7. search a string withing a string : find / search hangs
    By itarnak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2005, 11:05 AM

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