+ Reply to Thread
Results 1 to 6 of 6

How to remove leading blank spaces in front of any word in column

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    09-04-2007
    Location
    Ontario, Ca
    Posts
    624

    How to remove leading blank spaces in front of any word in column

    My 1st ll rows consist of a dashboard. There is not data in these 11 rows.

    I have 2 columns with data.

    Column 3 has a permanent list of names with no leading spaces.

    Column 8 has a list of names that:

    1. Some words have no leading blank spaces.
    2. Some words have 1 blank space in front of them.
    3. Some words have 2 blank spaces in front of any word.

    I need to have a macro that deletes all leading blank spaces in all words in column 8. When all leading blank spaces have been cleared, All the names in Column 8 need to be appended to column 3 at the bottom of the column.
    Last edited by Launchnet; 12-21-2011 at 01:23 PM. Reason: Mark as SOLVED
    Thanks for helping . . .
    Matt @ Launchnet

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: How to remove leading blank spaces in front of any word in column

    Try Text to Column by Highlight the column (1 column at a time) > Go to Data > Text to Column. Make sure you choose Delimited, and check space check box.

  3. #3
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: How to remove leading blank spaces in front of any word in column

    Hi

    try
      For i = 12 To Cells(Rows.Count, 8).End(xlUp).Row
        Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Value = Trim(Cells(i, 8).Value)
      Next i
    rylo

  4. #4
    Valued Forum Contributor
    Join Date
    09-04-2007
    Location
    Ontario, Ca
    Posts
    624

    Re: How to remove leading blank spaces in front of any word in column

    Good hearing from you rylo . . .

    Please look at the code on this reply. You will know better than by my trying to describe it.

    'Sorry, I forgot to tell you that all data in column 8, with the exception of rows 1 : 11.
    'Need code to delete all data from last name in column 8 up thru row 12


    Sub EliminateLeadingBlanks()
    Dim i
      For i = 12 To Cells(Rows.Count, 8).End(xlUp).Row
        Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Value = Trim(Cells(i, 8).Value)
      Next i
      'WORKS PERFECT TO HERE !
      
      
      
        'NEED CODE HERE  
      
      
    End Sub

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: How to remove leading blank spaces in front of any word in column

    Matt
    This just clears it out rather than deleting.

    range("H12:H" & cells(rows.count,"H").end(xlup).row).clearcontents
    rylo

  6. #6
    Valued Forum Contributor
    Join Date
    09-04-2007
    Location
    Ontario, Ca
    Posts
    624

    Re: How to remove leading blank spaces in front of any word in column

    Thanks Rylo . . .

    I sure enjoy how you code. It takes a certain type of programmer to have clean code like yours. You also knew immediately what I was asking for.

    It works perfect.

    I'll be sending you a private message in the near future. I am sure you can help me.

    Many Thanks and Merry Christmas To You and Yours,

    Matt & Macy Gentry

    I'll mark this solved.
    Last edited by Launchnet; 12-21-2011 at 12:20 AM. Reason: correct spelling and 2 words

+ 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