+ Reply to Thread
Results 1 to 6 of 6

Macro to delete spaces at end of a Cell

  1. #1
    Registered User
    Join Date
    06-29-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    33

    Macro to delete spaces at end of a Cell

    I have a spreadsheet that starts out with an employee name, followed by their employee ID in ( ) all in one cell, and then in the adjacent cell, the # of calls they took:
    A B
    John Doe (e123456) 30
    Jane Doe (e456789) 40

    I have a working macro that simply adds a column between A and B, then runs a Text to Columns with the ( as the delimter so it ends up:
    A B C
    John Doe e123456) 30
    Jane Doe e456789) 40

    Now the problem is my VLOOKUP on another worksheet looks for the name in column A and reports back with the # of calls in C. However, after the text to columns runs, it leaves a Space at the end of the name which causes VLOOKUP to not work.

    I have tried to create a macro that will uses =TRIM and overwrites the cell with the result. The space remover macro takes the macro that removes the space in one cell, and repeats that over and over.

    I have this spreadsheet saved as Stats Master.xls. The problem occurs when I take the master and save it to the Date: Stats April 28.xls. The text to columns macro continues to work, however, the space remover stops working because it says that it's referencing the macro that does the =TRIM in one cell as 'Stats Master.xls !SpaceRemove'.

    So does anyone have a macro that will remove the spaces at the end of all cells in A? Is there an easier way to do this that I am just missing?

  2. #2
    Registered User
    Join Date
    06-29-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Macro to delete spaces at end of a Cell

    Also, the space between the first and last names needs to stay...

  3. #3
    Registered User
    Join Date
    06-29-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Macro to delete spaces at end of a Cell

    Wow, I typed all that out and think I got it figured out from another post on another site I missed when I searched earlier....

    It looks like this has worked:
    Please Login or Register  to view this content.
    Last edited by davesexcel; 05-03-2012 at 07:10 PM.

  4. #4
    Forum Contributor
    Join Date
    07-24-2009
    Location
    Valrico, FL USA
    MS-Off Ver
    Excel 2016
    Posts
    358

    Re: Macro to delete spaces at end of a Cell


  5. #5
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Macro to delete spaces at end of a Cell

    This should work:

    Please Login or Register  to view this content.
    I hope that helps.
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  6. #6
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Macro to delete spaces at end of a Cell

    Haha yes Sponge that should be working too. Too bad I didn't refresh earlier instead of typing lol

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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