Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Wrap Custom Format (2000+)

    Hi Loungers,

    When formatting a text entry, it is possible to limit the width of the entry to the cell width by formatting the cell for wrapping.

    When formatting a number as a custom format which includes some words, such as a format
    ###0 "unique entries"
    is it possible to wrap the result? Or at least to throw in a line return (like ALT+Enter) between the number and the label? VBA or non-VBA solutions OK.

    Thanks.

    Fred

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Wrap Custom Format (2000+)

    While in format cells custom, Where you want the line to wrap: hold <alt> and enter 0010 from the numeric keypad. this will add the Linefeed character.

    Set the cell to wrap an it will wrap (format cells - alignment - wrap text)

    Be AWARE: the column width "autofit" will be unaware of the linefeed and the column will need to be the "full width" or it will fill it with ################ since it thinks it is too narrow to display the whole "number"

    Row autofit also does not work.

    These occur because the "cell" does not have the linefeed, the custom format does.
    Steve

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wrap Custom Format (2000+)

    You can put a line break in the number format by typing Alt+010.

    You can also do it in VBA, e.g. from the Immediate window:
    <pre>ActiveCell.NumberFormat = "#,##0" & Chr(10) & """unique entries"""
    </pre>

    Note that the literal text is surrounded by double double quotes within the double quotes.

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Wrap Custom Format (2000+)

    Another option is to use the TEXT function
    <pre>=TEXT(A1,"#,##0.0")&CHAR(10)&"unique entries"</pre>

    This works with autofit, rows and columns, but is no longer a number.

    VB would also make the cell no longer a number (you would use FORMAT and CHR functions instead of TEXT and CHAR functions in code.

    Steve

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Wrap Custom Format (2000+)

    Steve, Hans,

    Thanks for the quick responses. Seems like none of the approaches are perfect:
    - One of my purposes is to be able to make the column narrower since other entries are just a few digits wide. Inserting the linefeed but without being able to make the col narrower (resulting in the ##### "error") doesn't do what I want.
    - converting to text might be OK but I have to think on that

    Fred

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wrap Custom Format (2000+)

    Apparently, Excel can't handle line feeds in the cell format correctly, it calculates the column width as if there was no line break.

    In your example, why not put the number in one cell and the text into the cell below it?

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Wrap Custom Format (2000+)

    Hans,

    Thanks for that. That agrees with what Steve indicated (what a surprise).

    I had already created a custom format
    ###0 "unique entries"
    but the resulting col width was very wide compared to the other entries in the col (which were being counted for uniqueness). Thus I wanted to make the col narrower to more closely fit the other entries. Of course, that got me the #### error. That was the basis for the original question. Your idea of moving the "label" to the cell below would work too.

    Fred

Posting Permissions

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