+ Reply to Thread
Results 1 to 6 of 6

code to remove space

  1. #1
    Forum Contributor
    Join Date
    02-13-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    140

    code to remove space

    I have some alpha Numeric number in Column-B like below. Starts from cell B2

    DC-1
    D C - 1
    D C-2
    DC-2

    DC- 4

    DC-4
    DC-4


    DC -4
    10 02 4


    I need VBA code to Remove all spaces in the data. It should remove space from B2 to till the end of the last cell in column B

    like below

    DC-1
    DC-1
    DC-2
    DC-2

    DC-4

    DC-4
    DC-4


    DC-4
    10024

    Need only VBA. Not Formula

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: code to remove space

    If you are happy with a formula use this then copy and paste the results a values back into column A

    =SUBSTITUTE(A1," ","")
    Happy with my advice? Click on the * reputation button below

  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: code to remove space

    But... if you really want VBA

    then try this

    Change the 1000 to the number of lines you need to do

    Please Login or Register  to view this content.
    Last edited by Crooza; 08-16-2016 at 05:18 AM.

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    863

    Re: code to remove space

    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  5. #5
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: code to remove space

    Try this:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: code to remove space

    Hi,

    Only one line should be enough

    Please Login or Register  to view this content.
    You can achieve the same with the Replace dialogue very quickly as well.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

+ 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] Extra space or spaces in Text in Forum Post. BB Code for extra space ?
    By Doc.AElstein in forum The Water Cooler
    Replies: 21
    Last Post: 03-02-2016, 02:59 PM
  2. [SOLVED] How to remove empty space, unable to make pvot, because pvot calculate empty space
    By vengatvj in forum Excel Charting & Pivots
    Replies: 20
    Last Post: 10-29-2013, 12:43 PM
  3. [SOLVED] If Cell Starts with a Space, remove that space
    By Ocean Zhang in forum Excel General
    Replies: 2
    Last Post: 09-29-2012, 01:52 PM
  4. Simple code to locate a word and remove space in front
    By yiannis1925 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2011, 10:14 AM
  5. Remove after first space
    By orlycnd in forum Excel General
    Replies: 1
    Last Post: 01-11-2011, 10:36 AM
  6. how to remove space
    By avk in forum Excel General
    Replies: 3
    Last Post: 01-09-2010, 03:48 PM
  7. [SOLVED] Code / Add In to remove unnecessary white space
    By Gazza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2005, 06:05 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