+ Reply to Thread
Results 1 to 3 of 3

How To Substitute with different length text

  1. #1
    Registered User
    Join Date
    03-04-2020
    Location
    HKSAR
    MS-Off Ver
    2013
    Posts
    8

    How To Substitute with different length text

    Hi There,

    I need change Company Name with XXX, the rule is First word can show full, but start from second word, only first letter show it, the rest are show as "XXX".

    For example, ABC Company --> ABC CXXXX; ABC SUSAN COMPANY-->ABC SXXXX CXXXXXXX (The number of "XXX" no need same as the original number of letters.)

    The question is, since the length of Company name are very different, and the number of space (" ") are different too, how can I use substitute function to solve it?

    Thank you all!
    Attached Files Attached Files
    Last edited by sssyyy2002; 06-12-2020 at 01:04 PM.

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: How To Substitute wit different length text

    with your version (XL2013) this would be quite convoluted -- you would be better off using a Custom Function (stored in a standard Module); one basic approach:

    Please Login or Register  to view this content.
    which you could then call from your cell

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    formula wise... for 2013, accounting for up to 4 words:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    edit: formula wise - if you don't care how many Xs appear (say 4) then
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    the same can be achieved in the UDF by modifying the String function to use 4 rather than leverage the length of the string being masked
    Last edited by XLent; 06-12-2020 at 10:25 AM. Reason: added Application.Trim to UDF (to handle final element)

  3. #3
    Registered User
    Join Date
    03-04-2020
    Location
    HKSAR
    MS-Off Ver
    2013
    Posts
    8

    Re: How To Substitute wit different length text

    Thank you very much. You save my life. Really appericate, Thanks again!!!!

+ 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] Substitute Text
    By greatsyd in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-06-2018, 07:13 AM
  2. Can you increment text in a substitute text formula
    By Taupo58 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-20-2015, 03:45 AM
  3. Replies: 4
    Last Post: 10-28-2014, 11:04 PM
  4. [SOLVED] Substitute Text String
    By javeds in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-13-2014, 10:34 AM
  5. [SOLVED] Substitute text with a numeric value
    By Frasier013 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-01-2013, 01:52 AM
  6. How to use a substitute formula to substitute text entries to a different text entry
    By andybocchi in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-01-2010, 07:50 PM
  7. Substitute text
    By jeff.p in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2007, 05:01 PM

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