+ Reply to Thread
Results 1 to 5 of 5

Delete space in Text

  1. #1
    Registered User
    Join Date
    09-16-2005
    Posts
    32

    Delete space in Text

    Hello,
    does anyone know a macro that could remove the blanks or Space in cell C11 to C2000 (where there is text) Ex. 20 15 10
    Thanks in advance.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening herve

    This cheeky litle macro should do the trick.

    Sub RemoveSpaces()
    For Each UsrCell In Selection
    UsrCell.Value = Application.WorksheetFunction.Substitute(UsrCell.Value, " ", "")
    Next UsrCell
    End Sub

    Highlight the range you want it to effect before running it. That way, it will work on any range you later want to specify, not just C11:C2000.

    HTH

    DominicB

  3. #3
    Registered User
    Join Date
    09-16-2005
    Posts
    32
    hello Domincd
    thanks for the reply but could you tell me how to do it only for the cell C11 to C500
    without having to do a selection?
    Thanks

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi herve

    This will do the trick:

    Sub RemoveSpaces()
    Range("C11:C500").Select
    For Each UsrCell In Selection
    UsrCell.Value = Application.WorksheetFunction.Substitute(UsrCell.Value, " ", "")
    Next UsrCell
    End Sub

    HTH

    DominicB

  5. #5
    Dave Peterson
    Guest

    Re: Delete space in Text

    How about selecting C11:C2000 and then
    edit|Replace
    what: (spacebar)
    with: (leave blank)
    replace all

    If you need it as a macro, you can record it when you do it manually.

    herve wrote:
    >
    > Hello,
    > does anyone know a macro that could remove the blanks or Space in cell
    > C11 to C2000 (where there is text) Ex. 20 15 10
    > Thanks in advance.
    >
    > --
    > herve
    > ------------------------------------------------------------------------
    > herve's Profile: http://www.excelforum.com/member.php...o&userid=27314
    > View this thread: http://www.excelforum.com/showthread...hreadid=473046


    --

    Dave Peterson

+ 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