Home » excel » excel – How to shrink column width with multiple-line custom number formats?

excel – How to shrink column width with multiple-line custom number formats?

Posted by: admin May 14, 2020 Leave a comment


I discovered a trick, but Excel doesn’t want to cooperate fully… but maybe there’s a workaround…?

I often end up with a date/time on a “tall row” (since other columns are multi-line):

img 1-line

…and I’d like to save vertical space by splitting the date/time onto 2 lines, while keeping it a single numeric value for reasons of sorting, etc:

img 2-line

I realized that this can be accomplished by using a ␊LineFeed character in the custom number format, one of two ways:

Method #1: On a keyboard with a numeric keypad:

  1. Select the cell with the value.

  2. Hit Ctrl+1 to open the Number Formats dialog.

  3. Choose the Custom category and then in the Type: textbox:

    • Enter the first part of your custom format, ie. yyyy-mm-dd
    • While holding down Alt enter 0010 on the numeric keypad, and then release Alt
    • Enter the second part of your custom format, ie. HH:mm am/pm
  4. Hit Enter.

  5. Drag between the row headers to make the row twice as tall:

  6. If Wrap Text is not already on, click it on the Home tab of the ribbon: imgWordWrap

👉 Alt + 0010 enters a ␊LineFeed character.

Note: Since Excel doesn’t expect this character, the first line you enter in the Type box will disappear as soon as you enter the ␊LineFeed character. There’s no way to see it within the dialog (without deleting the ␊LineFeed), but it’s still there.

Method #2: On a keyboard without a numeric keypad and/or using VBA:

In the VBA Editor, either within your procedure, or in the Immediate Window (Ctrl + G), you can set the number format for A1 with something like:

Range("A1").NumberFormat="yyyy-mm-dd" & vbLf &  "HH:mm am/pm"

…then adjust the row height and make sure Wrap Text is on, via VBA or with steps #5 & 6 above.

👉 vbLf (or Chr(10)) represents a ␊LineFeed character in VBA.

My issue:

This is cool, but it seems that Excel still treats the value like it’s one long string on a single line.

This is demonstrated by:

  • double-clicking between column headers to AutoFit the column:
    The column does not “shrink” any further.
  • double-clicking between row headers to AutoFit the rows:
    The row does not “grow to double height”.
  • manually dragging the column to a narrower size.
    Excel “thinks” the value doesn’t fit:

           <img src="https://i.stack.imgur.com/TuBAZ.png" alt="Img



    Error”>         img

Any ideas for a workaround?

Perhaps there’s a hack to force Excel to display partial values instead of



when a formatted numeric value doesn’t fit?


How to&Answers:

You have to shrink-wrap it. See the OP’s edit here:

Prevent hash signs (#) showing up in Excel without changing cell format or width

1) Go to the Alignment tab in the Format Cells dialogue.
2) Select “Shrink to fit”.
3) Select “Wrap text”.
4) Click “OK”.

enter image description here

Excel will still auto-size the column to ~139 pixels, but you can drag the column width to ~71 pixels and still see both lines.


Make sure the Shrink to fit function is ticked

Go to: Right click on cell –> Format Cells –> Alignment –> Shrink to fit

Right click on cell

Click Shrink to Fit