Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 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: Formatting Canadian Postal Codes.

Formatting Canadian Postal Codes

Written by Allen Wyatt (last updated April 24, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


5

In Canada, postal codes consist of six characters with a space in the middle: a letter, a number, a letter, a space, a number, a letter, and a final number. Thus, A1B 2C3 is a properly formatted postal code. If you are retrieving postal codes from an external database, they might not have the required space in the middle. Excel makes it easy to add such a space.

Let's assume that the improperly formatted postal codes are in column C. In column D you could use a formula such as the following:

=LEFT(C12,3) & " " & RIGHT(C12,3)

This formula uses string-manipulation functions to place a space in between the first and last three characters. Thus, if C12 contained A1B2C3, then the cell with this formula would display A1B 2C3.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11167) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Formatting Canadian Postal Codes.

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

Automatically Running a Macro

Word allows you to create macros that can run at special times, automatically. This tip explains five special macros that ...

Discover More

Cropping Graphics

Excel makes it easy to place a graphic in a worksheet. Once there, you may want to chop off a side (or two) of the ...

Discover More

Changing Body Text to a Heading

When working on a document in Outline view, you may need to change regular body text to a heading in the outline. It's ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Counting Occurrences of Words

If you would like to determine how many instances of a particular word appear within a range of text, there are several ...

Discover More

Deriving Antilogs

Creating math formulas is a particular strong point of Excel. Not all the functions that you may need are built directly ...

Discover More

Compiling a List of Students in a Course

Need to pull just a limited amount of information from a large list? Here are a few approaches you might be able to use ...

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 + 8?

2023-11-18 09:47:01

Kurt Holzman

Thank you for this tip. If you change location to 'English (United States)' to 'English (Canada)' the only options Excel offers are Phone Number or Social Insurance Number. This tip is very helpful.


2021-05-09 08:04:20

Rod Grealish

UK postcodes can have two to four characters before the space, such as L1 for Liverpool 1 and G3 for Glasgow 3. The Wikipedia article on UK postcodes states that the following are the valid formats for UK postcodes.

AA9A 9AA
A9A 9AA
A9 9AA
A99 9AA
AA9 9AA
AA99 9AA

Rod


2021-05-02 12:13:31

Willy Vanhaelen

Here is even a one-liner version of my macro:

Sub AddSpaces()
Selection = Evaluate(Replace("LEFT(@,3)&"" "" & RIGHT(@,3)", "@", Selection.Address))
End Sub


2021-04-24 12:42:28

Willy Vanhaelen

@Hazel Kohler
The formula can be shorter:
=LEFT(A2,IF(LEN(A2)=6,3,4))&" "&RIGHT(A2,3)

@TWIMC
If you prefer to do it without helper column you can use this macro which does the changes right in your postal codes column:

Sub AddSpaces()
Dim cell As Range
For Each cell In Selection.Cells
cell = Left(cell, 3) & " " & Right(cell, 3)
Next cell
End Sub

To use it, select the postal codes you which to change and run the macro.


2021-04-24 08:31:52

Hazel Kohler

Postcodes in the UK can have 3 or 4 characters in the first group, but always 3 characters in the second group, after the space (e.g. AB1 1AB, or AB12 1AB). Adding an IF condition to the formula takes this into account - in my example, the code is in AA: IF(LEN(A2)=6,(LEFT(A2,3)&" "&RIGHT(A2,3)),(LEFT(A2,4))&" "&RIGHT(A2,3))


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.