+ Reply to Thread
Results 1 to 3 of 3

Substituting text but only if it is not part of another word

  1. #1
    Registered User
    Join Date
    09-14-2011
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    65

    Substituting text but only if it is not part of another word

    For example, I have an address in one cell and I want to get rid of the state. The state is not always in the same place so I was using =SUBSTITUTE and omitting the last bit which lets you choose which occurrence of the text you want to substitute, but my problem is that if the state appears as part of another word it does this:

    Original text = 123 SUNNY BUNNY LANE, NEW YORK, NY 123456 USA
    Substitute = 123 SUN BUN LANE, NEW YORK, 123456 USA

    How can I replace occurrences of "NY" only if it is on its own and not part of another word within the string?

    Thanks,

    Soph

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Substituting text but only if it is not part of another word

    If the addresses are consistently structured...
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    09-14-2011
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    65

    Re: Substituting text but only if it is not part of another word

    Not really because the addresses are not consistently structured (eg. in China the address needs to be sort of backwards so the state comes first).

    If only we lived in a world where everything was always consistent, I would be a very happy bunny indeed

+ 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. Substituting text
    By skatcb in forum Excel General
    Replies: 2
    Last Post: 06-15-2012, 08:04 AM
  2. Replies: 3
    Last Post: 04-06-2010, 11:26 PM
  3. Substituting text
    By TedH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2009, 03:31 PM
  4. [SOLVED] Replacing or Substituting Text
    By Naya in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2005, 10:05 PM
  5. [SOLVED] substituting two text occurances in same cell.
    By Hassan Alameh in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-09-2005, 10:06 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