+ Reply to Thread
Results 1 to 9 of 9

Replace Specific text with multiple occurance in a single cell

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    India
    MS-Off Ver
    2016
    Posts
    12

    Replace Specific text with multiple occurance in a single cell

    I want a excel VBA code that can replace Specific text with multiple occurance in a single cell with a number, example given below"
    If Range("A1") has value
    DX-12345, I am fine
    DX-3788277, How are you?
    I want to tell you xyz.

    DX-678900, I am coming at your home; DX-678900_NO
    DX-5432123, Come over.

    Then code should replace all the starting DX- with D1-, D2-, D3-, ad so on, example given below:

    D1-12345, I am fine
    D2-3788277, How are you?
    I want to tell you xyz.

    D3-678900, I am coming at your home; DX-678900_NO
    D4-5432123, Come over.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Replace Specific text with multiple occurance in a single cell

    Hi,

    Try this:

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    09-29-2021
    Location
    India
    MS-Off Ver
    2016
    Posts
    12

    Re: Replace Specific text with multiple occurance in a single cell

    Thank you for code :-)

    This working but it is also changing "DX" if it comes in between lines. I want to replace only the DX which is coming at the starting of the line
    There is one thing which can help modify this code, code should not change the value of "DX" if "; " comes before "DX", e.g, it should not replace "; DX"
    Please help!!

  4. #4
    Registered User
    Join Date
    11-27-2020
    Location
    Ahmedabad
    MS-Off Ver
    2013 and 2016
    Posts
    46

    Re: Replace Specific text with multiple occurance in a single cell

    if A1 text have always 5 occurrences of DX then Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-29-2021
    Location
    India
    MS-Off Ver
    2016
    Posts
    12

    Re: Replace Specific text with multiple occurance in a single cell

    Actually, occurrences of DX can vary

  6. #6
    Registered User
    Join Date
    11-27-2020
    Location
    Ahmedabad
    MS-Off Ver
    2013 and 2016
    Posts
    46

    Re: Replace Specific text with multiple occurance in a single cell

    It will handle till 10 Occurrences of DX

    If you give the info that what would be the maximum number of DX at starting then I will modify formula for you to cover all DX

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by alidurfani; 09-29-2021 at 08:02 AM.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Replace Specific text with multiple occurance in a single cell

    Try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-29-2021
    Location
    India
    MS-Off Ver
    2016
    Posts
    12

    Re: Replace Specific text with multiple occurance in a single cell

    There are at maximum 30 DX

  9. #9
    Registered User
    Join Date
    11-27-2020
    Location
    Ahmedabad
    MS-Off Ver
    2013 and 2016
    Posts
    46

    Re: Replace Specific text with multiple occurance in a single cell

    For up to 30 DX Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. Replace multiple Text in a single line
    By richard.lim85 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-02-2019, 04:52 AM
  2. Replies: 6
    Last Post: 11-19-2018, 09:46 AM
  3. USING VBA replace multiple strings in a single cell
    By AV114 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2018, 08:12 AM
  4. [SOLVED] Edit and replace long text in a single cell
    By adekinteristi in forum Excel General
    Replies: 8
    Last Post: 12-21-2017, 04:36 AM
  5. Replies: 9
    Last Post: 07-02-2015, 01:13 AM
  6. Replies: 2
    Last Post: 09-13-2011, 12:10 AM
  7. Search and replace text in cell with single character
    By piputty in forum Excel General
    Replies: 1
    Last Post: 08-05-2011, 10:32 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