Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Creating Two-Line Custom Formats.

Creating Two-Line Custom Formats

Written by Allen Wyatt (last updated September 8, 2023)
This tip applies to Excel 2007, 2010, 2013, 2019, and Excel in Microsoft 365


15

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:

Sat 13
April

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:

  1. Select the cells you want to format.
  2. Display the Home tab of the ribbon.
  3. Click the small icon at the bottom-right of the Number group. Excel displays the Number tab of the Format Cells dialog box.
  4. In the Category list, choose Custom. (See Figure 1.)
  5. Figure 1. The Number tab of the Format Cells dialog box.

  6. Delete whatever is in the Type box.
  7. Type "ddd d" without the quote marks.
  8. 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 6 disappears. It is not really gone; it has just moved up above what can be displayed in the Type box.
  9. Type "mmmm" without the quote marks.
  10. Click the Alignment tab. (See Figure 2.)
  11. Figure 2. The Alignment tab of the Format Cells dialog box.

  12. Make sure the Wrap Text check box is selected.
  13. 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 (12587) applies to Microsoft Excel 2007, 2010, 2013, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Creating Two-Line Custom Formats.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using TC Fields for Notes

The TC field is normally used in constructing manual Tables of Contents. The way the field works, however, makes it a ...

Discover More

Printing an Outline

Outlining is a great way to develop the content of your document. If you need to, you can even print the outline and only ...

Discover More

Excel Charts in PowerPoint

A common place to use Excel charts is in your PowerPoint presentations. How you paste those charts into the presentation ...

Discover More

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!

More ExcelTips (ribbon)

Understanding Date and Time Formatting Codes

Want to apply a custom format to your dates and times? To do it effectively you need to understand the custom formatting ...

Discover More

Decimal Tab Alignment

If you are familiar with decimal tabs in Word, you may wonder if you can set the same sort of alignment in Excel. The ...

Discover More

Displaying Numbers as Spaced Pairs

Custom formats can be very powerful in Excel, but not every formatting scenario can be addressed through the use of a ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

2023-09-08 12:04:45

David Bonin

I have also had the issue where the column has to be wide enough to fit the whole, unwrapped text, particularly with dates.

Here's your solution: Check both the "Shrink to fit" and "Wrap text" checkboxes. I think you have to check the shrink box first and then the wrap box. Or vice versa.

Either way, it works for me and I've been using this for years with two-line dates.


2021-07-04 05:20:46

Roy

If you can live with a text value and having to work it into a numeric value for any use further on in cells, or do not use it further on (it's no cell's precedent), then the following will allow "proper" column width:

=TEXT(source_of_value,"dddd"&CHAR(10)&"mmmm d, yyyy")

Of course, there's one huge caveat I've not mentioned: That won't very well allow direct entry into the cell. So if not reading from some source cell, it won't help you. Cheery news is though, that if you are...

Also, better than I wrote previously, make out the number format (date format in this case) without the line break/s. Then move backwards through it and place the line break/s as desired (moving right to left). That way you see all the typing that makes up the format since it stays on the one line Excel will ever display for you. You only lose sight of the rightmost stuff as you enter the break/s and you don't need sight of them anymore anyway.


2020-11-07 13:30:35

Rick Rothstein

Two comments about Step 7 in your tip...

1) Instead of typing ALT+0010 you can type CTRL+J and it will work the same way.

2) On my version of Excel, what I typed does not disappear when I type either of the keystrokes in #1 above; rather, the cursor seems to disappear... actually it has moved below the displayed field (if you look carefully, you can see what looks like a single blinking dot... that is the top of the blinking cursor that is now below the bottom of the Type textbox). While you cannot see what you are typing down there, you can watch the results of your typing in the Sample textbox.


2020-09-20 22:29:09

JJ

Only issue with this is it appears Excel forces a column width as though the line feed wasn't there (showing ####### in a column that would easily fit the 'text' of MMM[ALT0010]YYYY. Cool, but because of this became useless for me. When you expand it 'enough' there's alot of padding around the value in the column.


2020-09-03 12:37:42

Gloria

This did not work for me at all. I use excel 2019. I entered dddd then held alt key+0010 but nothing happened. Tried it with and without a space after the d's. Tested with the rest of the format mmmm d, yyyy. No matter what I do the entry looks like this
dddd mmmm d, yyyy and the result is Sunday June 13, 2021. I want Sunday to be on top with the date underneath. I have the format box checked for wrap text, so the actual spacing has the year on the 2nd line. The line break code is the part that did not work. UPDATE - I got the code to create after turning off the num lock - the format entry line now shows the format on the correct 2 lines but the data in the cell has not changed. I feel like I'm getting closer but it's still not working.


2019-06-27 06:24:13

nick soulsby

To Lorrie's point: The column width appears to need to be the same width as if there was no line break inserted, otherwise it displays as ####.
yes you can use a smaller font, but there is still a lot of "white space" used in the cell.
Any workarounds ?


2019-03-10 08:58:07

Willy Vanhaelen

@Lorrie
Use a smaler font.


2019-03-09 15:18:50

Lorrie Jo Williams

This worked, but the width of the cell still needs to be the width of the full text as one line to display (i.e., all I see is #####).
Is there a way to allow the column to be narrower?


2019-03-06 11:14:08

Willy Vanhaelen

@Peter
Here is a one-liner that does the job quicker because it doesn't use a loop

Sub FormatAddress()
Selection = Evaluate("IF({1},SUBSTITUTE(" & Selection.Address & ", "", "",CHAR(10)))")
End Sub

The Evaluate method uses Excel's SUBSTITUTE function and the IF function transforms it to an area formula.

@Cory
I think you want to split the address automatically at the moment you enter it. This can be done with this event macro (for column A):

Private Sub Worksheet_change(ByVal Target As Range)
If Target.Column <> 1 Or Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
Target = Replace(Target, ". ", vbLf)
Application.EnableEvents = True
End Sub

This macro must be entered in the code page of the sheet you want to use it in. Right click the sheet's tab and select "View Code...". That's the place to be.

If you want to use another column, adjust the column number in the first line: 2 for column B , 3 for C etc.


2019-03-05 10:15:26

Peter Atherton

Cory

This is best done with a macro. Try the following:

Sub FormatAddress()
'Make sure that you column is wide enough _
to take the longest part of the address _
before running the macro

Dim c As Range
Const Separator As String = ", "

For Each c In Selection
c = WorksheetFunction.Substitute(c, Separator, vbLf)
Next
End Sub

(see Figure 1 below)

Figure 1. 


2019-03-04 16:46:02

Cory

This is brilliant, however I'm trying to do it with addresses. Specifically, the user will type "123 Main St. Hometown, USA 12749" and I want it to auto-split after the first period. 1st line: 123 Main St. 2nd line Hometown, USA 12749"


2018-11-09 07:40:56

Cal

Hi Allen,


How do you perform this on a Mac?
Using the 'Option' key doesn't work.

Thanks


2018-11-07 08:21:01

Matt

Hi Allen

This tip doesn't seem to work when applying a format based on a conditional formatting rule. Do you know if there's a workaround for that case?

Thanks!


2018-11-05 10:41:54

Roy

You can always type the format string in a regular cell that wraps text so you can see it perfectly as you enter it. Then copy it (copy the cell contents IN the cell, not the cell itself, not the cell itself) and paste instead of typing to produce the custom format.

Except... it won't paste in the Alt-Enter. It brings it in as a space.

However, you can easily edit the string where the Alt-Enter's are needed. Since that is the only thing you are editing, and not the crafting of the string itself, you have no worries like the one you mention.

(Edit from the end, moving back, and you will always have everything at the start still displayed. It's easier to see you are putting them in the right place... because... after you place the first Alt-Enter, nothing after that is visible...)


2018-03-19 05:00:37

Tony Nixon

I don't know when I will need this but it certainly works, and I have tried it up to four lines, not just two. It is a little tricky not being able to see the format code you have actually created though, or at least check where you have put the line fee characters


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.