+ Reply to Thread
Results 1 to 13 of 13

Replace macro or trim macro cant work

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Replace macro or trim macro cant work

    HI I have a little problem. In on specific cell c34 I need to removed spaces but keep the leading zero.
    Try put this In cell c34 sp = space

    sp059053spsp061spsp063 If I use a replace macro recorded it remove the first zero.
    If I use below code it keep the first zero but don't remove the remaining spaces.

    Please have a look thanks

    Abjac

    Example of a code for trim but it only remove the first space and keep the zero.

    Please Login or Register  to view this content.
    Last edited by abjac; 09-04-2014 at 04:04 AM.

  2. #2
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Replace macro or trim macro cant work

    use
    Please Login or Register  to view this content.

  3. #3
    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,454

    Re: Replace macro or trim macro cant work

    Does this help?

    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".

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Replace macro or trim macro cant work

    @abjac

    you posted 645 times, so i think you will know the forumrules.

    Please post your code between tags ##
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Replace macro or trim macro cant work

    Sorry oeldere off course I know that just forgot to do it hehe

  6. #6
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Replace macro or trim macro cant work

    HI Lancer I tried with yours don't really know where to put this line in, tried some combinations but all fall. Could you show the hole code please.
    Sweep. Your code works brilliant its and replace but I guess the big difference is that it make it as text before. But it works perfect. Thanks allot
    Will wait for lancer before I close this. Thanks to both

    Sincerely
    Abjac

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Replace macro or trim macro cant work

    Please Login or Register  to view this content.
    Instead of

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Replace macro or trim macro cant work

    Hi AB33. it did remove the first space in the beginning and did not remove zeroes but it did not remove the remaining spaces.

    Thanks

    Abjac

  9. #9
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Replace macro or trim macro cant work

    Hi, abjac! Try this
    Please Login or Register  to view this content.
    or use sweep code

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Replace macro or trim macro cant work

    Trim does not remove zeros, but ONLY spaces. You need to use substitution or replace methods.

  11. #11
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Replace macro or trim macro cant work

    Sorry AB I write wrong it removed the first space but not the other. Thanks

    HI lancer your new one is working I added this line also to be sure it remove comme.

    Please Login or Register  to view this content.
    I guess this is not a trim code but nearly the same as the other from sweep thanks allot to all

    I will mark this as solved
    have a nice day thanks

    Abjac

  12. #12
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Replace macro or trim macro cant work

    You code will generate 2 char "'".
    Use this
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Replace macro or trim macro cant work

    oops......
    Last edited by lancer102rus; 09-04-2014 at 05:45 AM.

+ 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] Replace macro dont work in some cases.
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-25-2014, 06:07 AM
  2. Add work sheet, find and replace macro help!
    By Snaybot in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-13-2014, 01:36 PM
  3. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  4. Macro to replace and improve my partially manual work
    By mingali in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2009, 12:22 PM
  5. How to do a Macro to Trim SSN
    By davant95 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2009, 01:09 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