+ Reply to Thread
Results 1 to 5 of 5

Removing Leading Spaces in a column of data with VBA Code

  1. #1
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Removing Leading Spaces in a column of data with VBA Code

    I thought I solved this once before but I cannot find it in my past posts. It should be pretty simple.

    I have a column of data in column B. The column contains both numbers and text. The contents comes from an XML file that is converted to a worksheet. The has a random number of rows. For some reason the content has spaces in front of the contents. I need those leading spaces removed. Does anyone know a simple set of instructions in VBA code that can go through that column and remove those leading spaces?

    Thanks in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Removing Leading Spaces in a column of data with VBA Code

    You can use an adjacent column with the TRIM formula, copy down. Copy as value to their original column. Or write VBA code to do same (but it really is quite fast to use Trim copy then paste values

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Removing Leading Spaces in a column of data with VBA Code

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Removing Leading Spaces in a column of data with VBA Code

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    Thanks Mumps1 your code works great!!

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Removing Leading Spaces in a column of data with VBA Code

    You are very welocome.

+ 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] Trouble removing leading spaces
    By jp001 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-06-2017, 05:06 AM
  2. [SOLVED] Leading or trailing spaces code failing randomly
    By kay007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2015, 04:12 AM
  3. Removing spaces in column
    By Fugly in forum Excel General
    Replies: 6
    Last Post: 07-15-2013, 10:23 AM
  4. 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
  5. [SOLVED] Removing leading and trailing spaces
    By mangesh in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-18-2013, 05:25 AM
  6. How to remove leading blank spaces in front of any word in column
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2011, 12:19 AM
  7. Removing leading zeros in code
    By zakcat1972 in forum Excel General
    Replies: 3
    Last Post: 02-27-2008, 01:18 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