+ Reply to Thread
Results 1 to 4 of 4

Clear Text of specific character in a cell with VBA

  1. #1
    Registered User
    Join Date
    11-16-2022
    Location
    Lima
    MS-Off Ver
    365
    Posts
    1

    Post Clear Text of specific character in a cell with VBA

    Hi, I have the next table (I am attaching a spreadsheet, but I still describe the problem)

    | header1 |
    | --------------------------------------- |
    | 000Model Test0Model Val00User0 |
    | Perman000User0Model Name000000 |
    | 000Perman00000000000000000000Name |

    So I need to replace all Ceros with only one "," like this

    | header1 |
    | --------------------------- |
    | ,Model Test,Model Val,User, |
    | Perman,User,Model Name, |
    | ,Perman,Name |


    Is there a combination of formulas to do this? or with code in VBA?
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Clear Text of specific character in a cell with VBA

    Hi there,

    Take a look at the attached version of your workbook and see if it does what you need. It uses the following code:

    Please Login or Register  to view this content.
    The highlighted value may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,381

    Re: Clear Text of specific character in a cell with VBA

    How about

    Please Login or Register  to view this content.
    Last edited by JEC.; 11-17-2022 at 03:54 PM.

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Clear Text of specific character in a cell with VBA

    This will work as long as there are not more than 231 consecutive zeros in a cell (if you know there will not be more than 21 consecutive zeros in a cell, you can remove the 22 from the list in the For Each statement)...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 11-17-2022 at 10:10 PM.

+ 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. How to add a character before specific text in a cell
    By brajpalshishodia in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-25-2019, 12:57 PM
  2. How to add special character before specific text in a cell
    By brajpalshishodia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2019, 07:43 AM
  3. VBA MAcro to clear contents of specific cells if a specific cell contains text
    By muzzareilly in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2017, 12:47 PM
  4. How do I remove all text in a cell after a specific character?
    By Erik Millerd in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. How do I remove all text in a cell after a specific character?
    By Erik Millerd in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  6. How do I remove all text in a cell after a specific character?
    By moi in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  7. How do I remove all text in a cell after a specific character?
    By Erik Millerd in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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