Creating Two-Line Custom Formats
Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Creating Two-Line Custom Formats.
Excel is quite flexible in how it allows you to set up custom formats for displaying all sorts of values. Most custom formats are straightforward and easy to figure out, once you understand how custom formats work. (Custom formats and how to set them up has been discussed fully in other issues of ExcelTips.)
What if you want to create a two-line custom format, however? For instance, you may want to format a date so that the abbreviated day of the week and day of the month is on the first line, followed by the unabbreviated name of the month on the second line. Using such a format, a date would appear in a single cell in this manner:
Most of this can be done by the custom format "ddd d mmmm", but you need to figure out a way to add a line break between the "d" and the "mmmm". Excel won't let you press Alt+Enter between them, which is what you normally do to add a line break.
The solution is to use the numeric keypad to enter the desired line break in the format. Follow these steps to set it up:
- Select the cells you want to format.
- Choose Cells from the Format menu. Excel displays the Number tab of the Format Cells dialog box.
- In the Category list, choose Custom. (See Figure 1.)
Figure 1. The Number tab of the Format Cells dialog box.
- Delete whatever is in the Type box.
- Type "ddd d" without the quote marks.
- Hold down the Alt key while you press 0010 on the numeric keypad. This enters the line feed character, and it looks like the portion of the format you typed in step 5 disappears. It is not really gone; it has just moved up above what can be displayed in the Type box.
- Type "mmmm" without the quote marks.
- Click the Alignment tab. (See Figure 2.)
Figure 2. The Alignment tab of the Format Cells dialog box.
- Make sure the Wrap Text check box is selected.
- Click OK.
After setting up the format in this manner, you will need to adjust the row height of the formatted cells so that the entire two lines of the date will display.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2895) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Creating Two-Line Custom Formats.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Leave your own comment:
Comments for this tip:
Poser2662 23 Jun 2016, 09:23
This worked PERFECTLY!!!!! Thank you!
Thomas 20 Oct 2015, 11:19
Hello, I have been looking for a solution to this for a long time. But could you be a little more clear on this? May be do a video?
"Type "ddd d" without the quote marks.
Hold down the Alt key while you press 0010 on the numeric keypad. This enters the line feed character, and it looks like the portion of the format you typed in step 5 disappears. It is not really gone; it has just moved up above what can be displayed in the Type box.
Type "mmmm" without the quote marks."
Ken 20 Sep 2015, 03:20
I received an audible error when I tried pressing "Alt" and entering numbers in the "Type:" field under custom number format.I was only able to get this to work by turning on "Num Lock" and using the numbers under the letters. I do not have a full keyboard. I only have the numbers at the top (not a separate set of numbers/keypad on the right.)
Mitch 25 Mar 2015, 15:33
After Paula commented, I went back and tried chepox's simple instructions.
This time it worked -- hurrah!
I may not have executed his/her instructions properly earlier.
So I'm a happier camper now.
Paula 24 Mar 2015, 13:42
This worked perfectly for me once I came back and read the bit about shrink fit! Thanks!
Carlos 06 Mar 2015, 06:38
What chepox wrote worked for me!
Mitch 08 Oct 2014, 09:21
Chepox and Michael,
Thanks for your helpful comments.
But after following them closely, they still don't allow me to shrink the column to actual width of the custom-format-wrapped text.
I get the usual unfriendly "########" display when shrinking the column even a tiny bit past the auto-shrinked width.
So the column still remains considerably wider than it needs to be.
I'm using Excel 2010 in Windows 7.
chepox 07 Oct 2014, 13:20
You need to uncheck wrap text for the selected cell then select shrink to fit, afterwards, check wrap text back again. Now you can shrink the columns to the actual size of the text per line.
Michael (Micky) Avidan 07 Aug 2014, 07:53
It is very easy to define a small Event-Macro to AutoFit the column.
Assuming you are dealing with Columns A,B,C - all you ned is to type the following macro into the Sheet Module:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target.Columns, Columns("A:C")) Is Nothing Then Exit Sub
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
mitch 06 Aug 2014, 11:41
This tip gives a "line feed" (as "advertised") but the width the column needs to display the text is still the same (I'm using Excel 2010)
Thus, one cannot use this method to reduce the width of a column (a prime motivator for wrapping text).
Michael (micky) Avidan 14 Jul 2013, 08:10
@ machados soares,
Portable Computers have a special Fn key (usually in Blue) which toggles 10 keys on the keyboard to behave as the similar to the "Num Pad".
Ask your support dept. and/or check the Portable User guide/Manual.
“Microsoft®” MVP – Excel
machados soares 13 Jul 2013, 11:09
This tip doens't work on my portable.
I have windows 7 and excl xlsx.
I do everything inicated on the tip but it doens,t work.
Coul you help me please?