+ Reply to Thread
Results 1 to 5 of 5

VBA Code to delete trailing spaces:

  1. #1
    Registered User
    Join Date
    07-12-2014
    Location
    North Carolina
    MS-Off Ver
    Office 2007
    Posts
    79

    VBA Code to delete trailing spaces:

    All,
    I have a spreadsheet that has tons of numbers in Columns E & F that have trailing spaces (on the right side). This is making it impossible to format the cells as currency.

    I've tried Find & Replace (searching for " " and replacing with ""), I've tried using the trim function- neither worked.

    I guess what I'm looking for is just a piece of VBA code I can paste into a larger Macro that will remove blank spaces from the right side of all values in those columns. There will never be more than 1 space, and the change can be made for all values in those rows.

    Thanks in advance, I really appreciate it.

    Chad

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

    Re: VBA Code to delete trailing spaces:

    Try one of these
    use substitute function. You may have " ", not space, try to replace them with nil.

    OR

    Try to multiply both columns by 1. Put in 1 in any cell, then copy that cell, paste special multiply and see if they are converted in to numbers

  3. #3
    Registered User
    Join Date
    07-12-2014
    Location
    North Carolina
    MS-Off Ver
    Office 2007
    Posts
    79

    Re: VBA Code to delete trailing spaces:

    Hmmm. I'm not sure if it's a blank space or Nil. Could you take a look at the attached spreadsheet and let me know what I have and what the best way to get rid of it would be?

    Thanks Again
    Attached Files Attached Files

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

    Re: VBA Code to delete trailing spaces:

    Try the attached.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-12-2014
    Location
    North Carolina
    MS-Off Ver
    Office 2007
    Posts
    79

    Re: VBA Code to delete trailing spaces:

    That works- awesome. Thanks for putting that together for me!

+ 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] Remove Trailing Spaces
    By andrewc in forum Excel General
    Replies: 2
    Last Post: 09-18-2013, 12:56 PM
  2. Delete Trailing Spaces without Removing leading zeros WITHOUT TRIM
    By Zach51215 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2013, 04:24 PM
  3. Delete all trailing and leading spaces in multiple .csv files
    By rob_ford16 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-11-2013, 12:51 PM
  4. delete leading trailing and excessive spaces
    By djwaz69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-28-2012, 03:59 AM
  5. Delete trailing spaces & characters
    By bigband1 in forum Excel General
    Replies: 2
    Last Post: 03-06-2012, 04:24 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