+ Reply to Thread
Results 1 to 10 of 10

Macro doesn't delete space at the end of every number in column

  1. #1
    Forum Contributor
    Join Date
    12-11-2012
    Location
    Guadalajara, Mexico
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    101

    Macro doesn't delete space at the end of every number in column

    Hello. I have a file I need to make changes to before importing it to another workbook. I recorded a macro that makes the changes for me. In the code I have two questions. Column A:A has a series of numbers, but they contain a SPACE at the end of the number. I need to delete that space at the end of every number in the whole column. Why does it not delete the space at the end of each number in column A:A? It only deletes the one in the first cell A2. The macro must rename the sheet in that file TPCC always, but the name of the sheet will change from one month to the other for example this month its TreimentosPorCentroDeCusto but next month it could be TreimentosPorCentroDeCusto (4). How can it make the change no matter what the name might be? I have posted part of the code below for reference.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro doesn't delete space at the end of every number in column

    Hello Will03,

    Recorded macros rely on selecting cells and objects. In VBA, this is seldom necessary which is why VBA written macros tend to be shorter and faster. To properly convert your macro into to VBA it is necessary to see the recorded macro in its entirety. Please post your macro's complete code.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro doesn't delete space at the end of every number in column

    Does this help?

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    12-11-2012
    Location
    Guadalajara, Mexico
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    101

    Re: Macro doesn't delete space at the end of every number in column

    OK great but Actually I began to program the macro and got stuck when I came across that part so I recorded it. Sorry I'm still a rookie... Here is the entire code.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-11-2012
    Location
    Guadalajara, Mexico
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    101

    Re: Macro doesn't delete space at the end of every number in column

    @JohnDavis that worked great deleting the space at the end... Do you have any advise as far as the Renaming of the sheet? Its nice to see someone from Jersey here on the board I'm originally from North Arlington... Thanks

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Macro doesn't delete space at the end of every number in column

    @John
    Would it be better to use
    Please Login or Register  to view this content.
    instead of this
    Please Login or Register  to view this content.
    on the offset chance that it has numbers without a space?
    I realize that Will03 said that all the numbers have a space at the end but one never knows!

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro doesn't delete space at the end of every number in column

    North Arlington eh. Not far:

    Not the best solution, but maybe:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro doesn't delete space at the end of every number in column

    Quote Originally Posted by jolivanes View Post
    @John
    Would it be better to use
    Please Login or Register  to view this content.
    instead of this
    Please Login or Register  to view this content.
    on the offset chance that it has numbers without a space?
    I realize that Will03 said that all the numbers have a space at the end but one never knows!
    I agree with you, but Will03's first code should have worked in my opinion. The only thing I could think of is that the spaces he was seeing were actual not spaces but other characters. So I offered the Len solution.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Macro doesn't delete space at the end of every number in column

    @John
    OK, your thinking is ahead of my thinking.
    Thanks John

  10. #10
    Forum Contributor
    Join Date
    12-11-2012
    Location
    Guadalajara, Mexico
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    101

    Re: Macro doesn't delete space at the end of every number in column

    Thanks for the Help guys all done with the first part of the Macro and will begin part two... Hope if something comes up you may assist me as well. Here is the whole code working to perfection.

    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. [SOLVED] Delete that Extra Space Through the Entire Column
    By kooldis in forum Excel General
    Replies: 6
    Last Post: 05-07-2014, 03:25 AM
  2. Replies: 7
    Last Post: 10-23-2012, 08:38 AM
  3. [SOLVED] Macro to delete rows with zero in column deletes row that contain 0 in any number
    By Bjordion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2012, 02:55 AM
  4. Macro to delete first row and insert column after a certain number of column
    By arnab0711 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2011, 08:36 PM
  5. [SOLVED] How do I delete an extra space in every cell in a column?
    By iamjbunni in forum Excel General
    Replies: 2
    Last Post: 04-21-2006, 01:14 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