+ Reply to Thread
Results 1 to 4 of 4

Adding trailing blanks

  1. #1
    Registered User
    Join Date
    06-26-2008
    Location
    Asia
    Posts
    53

    Adding trailing blanks

    Hi.

    Does anyone know how to set the format of a cell such that it will automatically add trailing blanks to the data entered into that cell while fixing the number of characters that could be entered into that cell?

    Thanks.
    Friend
    Last edited by friend11_6; 07-14-2009 at 11:47 AM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Adding trailing blanks

    Not sure about the trailing spaces, but to control length use Data Validation, Text Length option.

  3. #3
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Adding trailing blanks

    There are several ways to achieve this.. one way is by formula..
    Assuming that if the length of text is less than 8 then you want space to make the length 8 you can use the below formula



    Enter the below formula
    Please Login or Register  to view this content.
    After applying the formula you can do copy -> paste special -> values..

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Adding trailing blanks

    You can't alter the physical content of a cell using a Custom Format - you can alter it's appearance however, ie:

    @*.

    would "appear" to fill up the remainder of a cell up with full stops though underlying value remains just the initial text (the . would print however).

    If you want to physically alter the content of the cell you would need to use either a formula to correct in another cell or a VBA change event to alter the cell upon entry... so say you wanted A1:A10 to be a max of 8 characters with surplus characters filled with a space:

    Please Login or Register  to view this content.
    As Palmetto has said you could use Data Validation to restrict length but given you need to alter the value with VBA you may as well validate there also - Validation can on occasion be circumvented (copy & paste etc...)
    Last edited by DonkeyOte; 07-09-2009 at 10:01 AM.

+ 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