Consulting

Results 1 to 15 of 15

Thread: How to remove the blank space which is present at the end of the value in a cell

  1. #1

    How to remove the blank space which is present at the end of the value in a cell

    Hello Everyone,

    Can anyone let me know how to remove the blank space present at the end of the value in the cell?

    I want this to happen for all the cell in the column and this should not affect the data in other columns.

    I have attached an example in which for column B all the spaces present after th e Product name should be deleted.

    Thanks in advance,
    Prashanth

  2. #2
    VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    You cant do it that I know of. The column heading is the problem. That is what is keeping the white space at the end of the data. Essentially, you can't make the column 2 different sizes.
    Peace of mind is found in some of the strangest places.

  3. #3

    Trim

    Use trim(cell) to elimintate leading and trialing spaces.
    For example in cell D2 write formula =TRIM(B2) then autofill downwards up to D11. Then copy range D211, select B2 and do pastspecial (onlyvalue).
    You can do this even by VBA.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I you just want to make Column B narrower, wrap the text in B1 and adjust the row height to suit.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Malcomb,

    I think she was after leaving the heading alone and trimming the values underneath, which is not possible. Yours is the best solution. And the only one that works.
    Peace of mind is found in some of the strangest places.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sorry guys, am I missing something here. The product names have trailing spaces, that is what is required to be removed is it not (for which paolo2504 gave a solution)?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Thanks guys,

    "Trim" is what i wanted.

    Regards
    Prashanth

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I only ckecked B11 which had no extra spaces!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    ..."Ahhh, I wonder if this filename is a clue. Watson, look up the Latin for Delete spaces..."



    ( a friendly tease of course)

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by mdmackillop
    I only ckecked B11 which had no extra spaces!
    LOL! Sod's Law.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    Quote Originally Posted by GTO
    ..."Ahhh, I wonder if this filename is a clue. Watson, look up the Latin for Delete spaces..."



    ( a friendly tease of course)
    I am sorry Sherlock holmes , next time i will explain my requirements much more clearly.

  12. #12
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by GTO
    ..."Ahhh, I wonder if this filename is a clue. Watson, look up the Latin for Delete spaces..."



    ( a friendly tease of course)
    .
    That was meant for me!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  13. #13
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Dear prshnthvn,

    My apologies if you took any offense, but indeed, that was meant for the good Mr. MacKillop; just an affectionate jab.

    I must say, I learn here even when just engaging in jest. Murphy's law would be the common expression here, but they are not exactly the same!

    Murphy's Law
    http://en.wikipedia.org/wiki/Sods_law
    Sod's Law
    http://en.wikipedia.org/wiki/Sod%27s_law

  14. #14
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by GTO
    I must say, I learn here even when just engaging in jest.
    That is what makes VBAX the best site around, you learn more than just Excel
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  15. #15
    Quote Originally Posted by GTO
    Dear prshnthvn,

    My apologies if you took any offense, but indeed, that was meant for the good Mr. MacKillop; just an affectionate jab.

    I must say, I learn here even when just engaging in jest. Murphy's law would be the common expression here, but they are not exactly the same!

    Murphy's Law
    http://en.wikipedia.org/wiki/Sods_law
    Sod's Law
    http://en.wikipedia.org/wiki/Sod%27s_law
    Dear GTO,
    No offense taken. Actually if you see this thread, many of them have mis-understood my question in the beginning, thats why i thought that you are telling that to me. And i did not understand the joke at the first and i actually translated "delete spaces" in to latin which is "delete tractus" which made no sense and after carefully reading your comment once again i understood you are talking to sherlock holmes watson. Its a good joke.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •