This tutorial about cell format types in Excel is an essential part of your learning of Excel and will definitely do a lot of good to you in your future use of this software, as a lot of tasks in Excel sheets are based on cells format, as well as several errors are due to a bad implementation of it.
A good comprehension of the cell format types will build your knowledge on a solid basis to master Excel basics and will considerably save you time and effort when any related issue occurs.
A- Introduction
Excel software formats the cells depending on what type of information they contain.
To update the format of the highlighted cell, go to the “Home” tab of the ribbon and click, in the “Number” group of commands on the “Number Format” drop-down list.
The drop-down list allows the selection to be changed.
Cell formatting options in the “Number Format” drop-down list are:
- General
- Number
- Currency
- Accounting
- Short Date
- Long Date
- Time
- Percentage
- Fraction
- Scientific
- Text
- And the “More Number Formats” option.
Clicking the “More Number Formats” option brings up additional options for formatting cells, including the ability to do special and custom formatting options.
These options are discussed in detail in the below sections.
Cell format types in Excel are: General, Number, Currency, Accounting, Date, Time, Percentage, Fraction, Scientific, Text, Special (Zip Code, Zip Code + 4, Phone Number, Social Security Number), and Custom. You can get them from the “Number Format” drop-down list in the “Home” tab, or from the launcher arrow below it.
I will detail each one of them in the following sections:
1- General format
By default, cells are formatted as “General”, which could store any type of information. The General format means that no specific format is applied to the selected cell.
When information is typed into a cell, the cell format may change automatically. For example, if I enter “4/4/19” into a cell and press enter, then highlight the cell to view details about it, the cell format will be listed as “Date” instead of “General”.
Similarly, we can update a cell’s format before or after entering data to adjust the way the data appears. Changing the format of a cell to “Currency” will make it so information entered is displayed as a dollar amount.
Typing a number into this cell and pressing enter will not just show that number, but will instead format it accordingly.
Before pressing enter, Excel shows the value which was typed: “4”.
After pressing enter, the value is updated based on the formatting type selected.
Don’t let the format type showed in the illustration at the drop-down list confusing you; it is reflecting the cell below (i.e. E4), since we validated by an Enter.
2- Number format
Cells formatted as numbers behave differently than general formatted cells. By default, when a number is entered, or when a cell is formatted as a number already, the alignment of the information within the cell will be on the right instead of on the left. This makes it easier to read a list of numbers such as the below.
Note in the above screenshot that since we didn’t choose the “Number” format for our cells, they still have a “General” one. They are numbers for Excel (meaning, we can do calculations on them), but they didn’t have yet the number format and its formatting aspects:
You can set the formatting options for Excel numbers in the “Format Cells” dialog box.
To do that, select the cell or the range of cells you want to set the formatting options for their numbers, and go to the “Home” tab of the ribbon, then in the “Number” group of commands, click on the launcher of the dialog box (the arrow on the right-down side of the group).
Excel opens the “Format Cells” dialog box in its “Number” tab. Click in the “Category” pane on “Number”.
- In this dialog box, you can decide how many decimal places to display by updating options in the “Decimal places” field.
Note that this feature is also available in the “Home” tab of the ribbon where you can go to the “Number” group of commands and click the Increase Decimal or Decrease Decimal buttons.
Here is the result of consecutive increasing of decimal places on our example of data (1 decimal; 2 decimals; and 3 decimals):
- You can also decide if commas should be shown in the display as a thousand separator, by updating the “Use 1000 Separator (,)” option in the “Format Cells” dialog box.
This feature is also available in the “Home” tab of the ribbon by clicking the “Comma Style” button in the “Number” group of commands.
Note that using the Comma Style button will automatically set the format to Accounting.
- Another option from the Format Cells dialog box is to decide how negative numbers should display by using the “Negative numbers” field.
There are four options for displaying negative
numbers.
- Display
negative numbers with a negative sign before the number. - Display
negative numbers in red. - Display
negative numbers in parentheses. - Display
negative numbers in red and in parentheses.
3- Currency format
Cells formatted as currency have a currency symbol such as a dollar sign $ immediately to the left of the number in the cell, and contain two numbers after the decimal by default.
The alignment of numbers in currency formatted cells will be on the right for readability.
Currency formatting options are similar to
number formatting options, apart from the currency symbol display.
- As with regular number formatting, you can decide, in the “Format Cells” dialog box, how many decimal places to display by updating the field “Decimal places”.
You can also find this feature in the “Home” tab of the ribbon, by going to the “Number” group of commands and clicking the Increase Decimal or Decrease Decimal .
- You can also decide what currency symbol should be shown in the display by updating the “Symbol” field in the “Format Cells” dialog box.
- As with regular number formatting, you can also decide how negative numbers should display by updating the “Negative numbers” field in the “Format Cells” dialog box.
There are four
options for displaying negative numbers.
- Display
negative numbers with a negative sign before the number. - Display
negative numbers in red. - Display
negative numbers in parentheses. - Display
negative numbers in red and in parentheses.
4- Accounting format
Like with the currency format, cells formatted as accounting have a currency symbol such as a dollar sign $; however, this symbol is to the far left of the cell, while the alignment of numbers in the cell is on the right. Accounting numbers contain two numbers after the decimal by default.
Clicking the “Accounting Number Format” button in the “Number” group of commands of the “Home” tab, will quickly format a cell or cells as Accounting.
The down arrow to the right of the Accounting Number Format button allows selection between common symbols used for accounting, including English (dollar sign), English (pound), Euro, Chinese, and French symbols.
Accounting formatting options in the “Format Cells” dialog box (“Home” tab of the ribbon, in the “Number” group of commands, click on the launcher of the “Number Format” dialog box), are similar to number and currency formatting options.
- You can decide how many decimal places to display by updating its option in the “Format Cells” dialog box.
As mentioned before in this tutorial, this feature is also available directly in the “Home” tab of the ribbon by clicking the Increase Decimal or Decrease Decimal buttons in the “Number” group of commands.
- You can also decide in the “Format Cells” dialog box, what currency symbol should be shown in the display by using the “Symbol” drop-down list.
This dropdown gives a much broader list of options than the “Accounting Number Format” option in the “Home” tab of the ribbon.
Note that with the Accounting formatting option, negative numbers display in parentheses by default. There are not options to change this.
5- Date format
There are options for “Short Date” and “Long Date” in the “Number Format” dropdown list of the “Home” tab.
Short date shows the date with slashes separating month, day, and year. The order of the month and day may vary depending on your computer’s location settings.
Long date shows the date with the day of the week, month, day, and year separated by commas.
More options for formatting dates are available in the “Format Cells” dialog box (accessible by clicking in the “Number Format” dropdown list of the “Home” tab and choosing the “More Number Formats” option at the bottom).
- You can choose from a long list of available date formats.
- You can update the location settings used for formatting the date. This will alter the list of format options in the above list and will adjust the display and potentially the order of the elements (day, month, year) within the date.
Note the below example when we switch from English (United States) format to English (United Kingdom) format.
6- Time format
Cells formatted as time display the time of
day. The default time display is based on your computer’s location settings.
Time formatting options are available in the “Format Cells” dialog box (accessible by choosing the “More Number Formats” option at the bottom of the “Number Format” dropdown list in the “Home” tab of the ribbon).
- You can choose from a long list of available time formats.
- You can update the location settings used for formatting the time. This will alter the list of format options in the above list and will adjust the display.
7- Percentage format
Cells formatted as percentage display a percent sign to the right of the number. You can change the format of a cell to a percentage using the “Number Format” dropdown list, or by clicking the “Percent Style” button . Both options are accessible from the “Home” tab of the ribbon, in the “Number” group of commands.
Note that updating a number to a percentage
will expect that the number already contains the decimal. For example:
A cell containing the value 0.08, as a percentage, will show 8%.
A cell containing the value 8, as a percentage, will show 800%.
Percentage formatting options are available in the “Format Cells” dialog box, accessible by clicking on “More Number Formats” of the “Number Format” dropdown list in the “Home” tab of the ribbon.
8- Fraction format
Cells formatted as a fraction display with a slash
symbol separating the numerator and denominator.
Fraction formatting options are available in the “Format Cells” dialog box, accessible by clicking in the “Home” tab of the ribbon, on “More Number Formats” of the “Number Format” dropdown list.
- Note that
when selecting the format to use for a fraction, Excel will round to the
nearest fraction where the formatting criteria can be met.
As an example, if the
formatting option selected is “Up to one digit”, entering a fraction with two
digits will cause rounding to occur. For example, with the setting of “Up to
one digit”,
If we enter a value of 7/16, the value displayed will be 4/9, as converting to 9ths was the option with only one digit which required the least amount of rounding.
For another example, if the formatting option selected is “As quarters”, entering a fraction that cannot be expressed in quarters (divisible by four) will also cause rounding to occur.
If we enter a value of 5/8, the value displayed will be 3/4. Excel rounded up to 6/8, or 3/4, which was the closest option divisible by four.
- Also note
that for the formatting options with “Up to x digits”, Excel will always round
down to the lowest exact equivalent fraction when possible.
For example, if we enter a value of 2/4 with one of these formatting options active, the value displayed will be 1/2, as this is the mathematical equivalent. This behavior will not take place for formatting options “As…”, since these specifically determine what the denominator should be.
- Fractions listed as more than a whole (meaning the numerator is a higher number than the denominator), such as 7/4 will automatically be adjusted into a whole number and a fraction 13/4, where the fraction follows the formatting rules selected.
9- Scientific format
Scientific format, otherwise known as
Exponential Notation, allows very large and small numbers to be accurately
represented within a cell, even when the size of the cell cannot accommodate
the size of the numbers.
The way exponential notation works is to theoretically place a decimal in a spot that would make the number shorter, then describe where to move that decimal to return to the original number.
Examples with large numbers, where the decimal is moved to the left:
For the number 300 to be expressed in
exponential notation, Excel moves the decimal from after the whole number
300.00 to between the 3 and the 00. This is typed out as E+02 since the decimal
was moved two places to the left. The other examples are similar, where the
decimal was moved 6 and 12 places to the left.
Examples with small numbers, where the decimal is moved to the right:
For the number 0.2 to be expressed in
exponential notation, Excel moves the decimal to create a whole number 2. This
is typed out as E-01 since the decimal was moved one place to the right. The
other examples are similar, where the decimal was moved 4 and 10 places to the
right.
Scientific formatting options are listed in the “Format Cells” dialog box, accessible by going to the “Home” tab of the ribbon, and clicking the “More Number Formats” option of the “Number Format” dropdown list.
The only option available is to alter the
number of decimal places shown in the number prior to the scientific notation.
For example, for the value 11.43 formatted with the scientific format, if we change the Decimal places from 2 to 1, the display will change as follows.
Two decimals:
One decimal:
10- Text format
Cells can be formatted as Text through the
“Number Format” dropdown list, in the “Number” group of commands of the “Home”
tab.
Using the Text format in Excel allows values to be entered as they are, without Excel changing them per the above formatting rules.
In general, when entering a text in a cell, you won’t need to set its type to “Text”, as the default format type “General” is sufficient in most cases.
This may be useful when you want to display numbers with leading zeros, want to have spaces before or after numbers or letters, or when you want to display symbols that Excel normally uses for formulas.
Below are examples of some fields formatted as Text.
Note that when a number is formatted as Text, Excel will display a symbol showing that there could be a possible error .
Clicking the cell, then clicking the pop-up icon will show what the error may be and offer suggestions for resolution.
11- Special format
Special format offers four options in the “Format Cells” dialog box, accessible by going to the “Home” tab of the ribbon, and clicking the launcher arrow in the “Number” group of commands.
- Zip Code
When less than five numbers are entered in Zip
Code format, leading zeros will be added to bring the total to five numbers.
When more than five numbers are entered in Zip Code format, all numbers will be displayed, even though this does not meet the format criteria.
- Zip Code + 4
Zip Code + 4 format automatically creates a
dash symbol – before the last four numbers in the zip code.
When less than nine numbers are entered in Zip
Code + 4 format, leading zeros will be added to bring the total to nine
numbers.
When more than nine numbers are entered in Zip Code + 4 format, extra numbers are displayed prior to the dash symbol –.
- Phone Number
Phone Number format automatically creates a
dash –
before the last four numbers in the phone number. This format also adds
parentheses ( ) around the area code when an area code is entered.
When less than the expected number of digits
are entered in Phone Number format, only the entered digits will be displayed,
starting from the end of the phone number, as shown on the third and fourth
lines, below.
When more than the expected number of digits
are entered in Phone Number format, extra numbers are displayed within the area
code parentheses.
Note that Phone Number format in Excel does not handle the number 1 before an area code. This entry would be treated like any other extra number.
- Social Security Number
Social Security Number format automatically
creates a dash – before the last four numbers in the social security number
and a dash before the last six numbers in the social security number.
When less than nine numbers are entered in
Social Security Number format, leading zeros will be added to bring the total
to nine numbers.
When more than nine numbers are entered in Social Security Number format, extra numbers are displayed prior to the first dash –.
12- Custom format
Custom formats can be used or added through the
“Format Cells” dialog box, accessible from the “Number” group of commands in
the “Home” tab of the ribbon by clicking the “Number Format” launcher arrow.
This can be useful if the above formatting options do not work for your needs. Custom number formats can be created or updated by typing into the “Type” field of the “Format Cells” dialog box.
When creating a new custom format, be sure to use an existing custom format that you are okay with changing.
Custom number formats are separated, at
maximum, into four parts separated by semicolons ; .
- Part 1: How
to handle positive number values - Part 2: How
to handle negative number values - Part 3: How
to handle zero number values - Part 4: How
to handle text values
Note that if fewer parts are included in the custom format coding, Excel will determine how best to merge the above options: As an example, if two parts are listed, positive and zero values will be grouped.
Note that Excel may update the formatting of some fields to Custom automatically depending on what actions are taken on the field.
C- Common issues caused by wrong cell format types in Excel
1- Common issues due to wrong cell format types in Excel
The most common problems you may encounter with a wrong cell format type in Excel are of 3 types:
– Getting a wrong value.
– Getting an error.
– Formula displayed as-is and not calculated.
Let’s illustrate these 3 cases with some examples:
- Getting a wrong value
This may occur when you enter a value in an already formatted cell with an inappropriate format type, or when you apply a different format to a cell already containing a value.
The following table details some examples:
- Getting an error
This occurs when you enter a text preceded with a symbol of a dash, or plus, or equal, as an element of a list.
Excel wrongly interprets the text as a formula and show the error “The formula contains unrecognized text”.
- Formula displayed as-is and not calculated
In the following example, we tried to calculate the total of prices from cell B2 to B6 using the Excel SUM function, but Excel doesn’t calculate our formula and just displayed it as-is.
The source of the problem is that the result cell, B7, was previously formatted as text before entering the formula.
2- How to correct wrong cell format type issues in Excel
To correct cell format type issues in Excel, apply the right format in the “Number Format” drop-down list, and sometimes, you’ll also need to re-enter the content of the cell. For cells with formulas displayed as text, choose the “General” format, then double click in the cell and press Enter.
Jeff Golden is an experienced IT specialist and web publisher that has worked in the IT industry since 2010, with a focus on Office applications.
On this website, Jeff shares his insights and expertise on the different Office applications, especially Word and Excel.
Formatting Data in Excel (Table of Contents)
- Formatting in Excel
- How to Format Data in Excel?
Introduction to Data Formatting in Excel
Data Formatting in excel is very useful, which allows us to format the data in any way we want. We can change the format of data to make it as per standards or our requirements. This brings uniformity in terms of the same type of fonts, shapes, alignment and font color. This is normally used in all types of work such as official, report creation, anything we want to print. This also allows other people to read and understand the meaning properly if everything is in the standard format.
There are a lot of ways to format data in excel. Follow the below guidelines while formatting the data/report in excel:
- The column heading/row heading is a very important part of the report. It describes the information about data. Thus, the heading should be in bold. The shortcut key is CTRL + B. It’s also available in the Font section in the toolbar.
- The header font size should be larger than the other content of the data.
- The header field background color should be other than white color so that it should be properly visible in the data.
- Make the outline border of the heading field. There are a lot of border styles. For border style, Go to the Font section and click on an icon as per the below screenshot:
- Choose the appropriate border style. With this, we can add a border of the cells.
- The header font should be aligned in the center.
- To make the size of cells enough, so that the data written within the cell should be in a proper reading manner.
- For number formatting, there are a lot of styles available. For this, Go to the number section and click on the combo box like the below screenshot:
- Depending on the data, whether it should be in decimal, percentage, number, date, or formatting can be done.
In the below image, we have shown different font styles:
“B” is to make the font bold, “I” is for italic, “U” is for make underline, etc.
How to Format Data in Excel?
Let’s take the below data and will understand the data formatting in excel one by one.
You can download this Data Formatting Excel Template here – Data Formatting Excel Template
Formatting in Excel – Example #1
We have the above-unorganized data, which is looking very simple. Now we will do data formatting in excel and will make this data in a presentable format.
- First, select the header field and make it bold.
- Select the whole data and choose the “All Border option” under the border.
So the Data will look like this :
- Now select the header field and make the thick border by selecting the “Thick box border” under the border.
After that, the Data will look like this :
- Make the header field in the center.
- Also, choose a background color other than white. Here we will use a light blue color.
Now the data is looking more presentable.
Formatting in Excel – Example #2
In this example, we will learn more about the style of formatting the report or data.
Let’s take an example of weather prediction of different cities day wise.
Now we want to highlight the Wednesday data.
- Select the whole records of that data and do the right-click. A drop-down box will appear. Select the “Format Cells” option.
- This will open a Format Cells dialog box. As we can see, there are a lot of options available to change the font style in various styles as we want.
- Through the Number button, we can change the data type like decimal, percentage etc.
- Through the Alignment button, we can align the font in a different style.
- Click on the Font button. This button has a lot of font styles available. We can change the font type, style, size, color etc.
- In this example, we are choosing a bold font size of 12, the color of Orange. We also can make the border of this data to look more visible by clicking on the Border button.
- Now our data is looking like the below screenshot:
Formatting in Excel – Example #3
Again we are assuming the same data. Now we want to present this data in pictorial format.
- Select whole data and go to the Insert menu. Click on Column Chart, Select Stacked Column under 2-D Column Chart.
- Our Data will look like as below:
Benefits of Data Formatting in Excel:
- Data looks more presentable.
- Through formatting, we can highlight specific data like profit or loss in business.
- Through the chart, we can easily analyze the data.
- Data Formatting saves a lot of time and effort.
Things to Remember
- There are a lot of shortcut keys available for data formatting in excel. Through which we can save a lot of time and effort.
- CTRL+B – BOLD
- CTRL+I – ITALIC
- CTRL+U – UNDERLINE
- ALT+H+B – Border Style
- CTRL+C – Copy the data, CTRL+X – Cut the data, CTRL+V – Paste the data.
- ALT+H+V – It will open the paste dialog box. Here a lot of paste options available.
- When we insert the chart for the data as we created in Example 3, it will open the chart tools menu. Through this option, we can do the formatting of the chart as per our requirements.
- Excel provides a very interesting feature through which we can do a quick analysis of our data. For this, Select the data and do the right-click. It will open a list of items. Select the “Quick Analysis” option.
- It will open the conditional formatting toolbox.
We can add more conditions in the data through this option, like if data is less than 40 or greater than 60, so how the data look in this condition.
Recommended Articles
This has been a guide to Formatting in Excel. Here we discuss how to Format Data in Excel along with excel examples and downloadable excel templates. You may also look at these useful functions in excel –
- Excel VBA Format
- Format Cells in Excel
- Excel Conditional Formatting for Dates
- Excel Date Format
What Is Excel Format Cells?
Formatting cells in Excel is one of the key options used to format the data. We can format data in different formats, such as time, date, currency, font, etc.,
For example, using format cells in excel, we can format time. If the value is 1800 hrs and we want to format it based on hh:mm AM/PM format, we can use the format cells option. As soon as we click format, the 1800 hrs will be formatted into 06:00 PM.
Table of contents
- What Is Excel Format Cells?
- How To Format Cells In Excel?
- Examples
- Important Things To Remember
- Frequently Asked Questions (FAQs)
- Recommended Articles
- Format cells in excel are used to format the data in the worksheet to present well and to save time.
- The tabs available in the Format cells option in excel are number, alignment, font, border, fill, and protection.
- Using the Number tab, we can format values such as date, currency, time, percentage, fraction, scientific notation, accounting number, etc., in excel.
- The shortcut keys to format date (in dd-mm-yy format) are Ctrl+Shift+#.
- Similarly, the shortcut keys to format time in hh:mm AM/PM format is [email protected]
How To Format Cells In Excel?
Formatting cells in excel is really simple. Let us have a look at the following examples to learn how to use format cells in excel.
You can download this Format Cell Excel Template here – Format Cell Excel Template
Examples
Example #1 – Format Date Cell
Excel stores date and time as serial numbers. We need to apply an appropriate format to the cell to see the date and time correctly.
For example, look at the below data.
It looks like a serial number to us, but we get date values when applying date format in excel to these serial numbers.
The date has a wide variety of formats. Below is a list of formats we can apply to dates.
We can apply any formatting codes to see the date, as shown above in the respective format.
- To apply the date format, we must first select the range of cells and press Ctrl + 1 to open the format window. Then, under Custom, we must apply the code as we want to see the date.
Format Cells Shortcut Key
We get the following result.
Example #2 – Format Time Cell
As we said, the date and time are stored as serial numbers in Excel. Now, it is time to see the TIME formatting in excel. For example, look at the numbers below.
The TIME values are varied from 0 to less than 0.99999, so let us apply the time format to see the time. Below are the time format codes we can generally use:
“h:mm:ss”
To apply the time format, we must follow the same steps:
So, we get the following result.
So, the number “0.70192” equals the time of 16:50:46.
If we do not want to see the time in the 24-hour format, we need to apply the time formatting code like the one below.
Now, we will get the result as shown in the below image.
Now, our time is shown as 04:50:46 PM instead of 16:50:46.
Example #3 – Format Date And Time Together
The date and time are together in Excel. We can format both the date and time together in Excel. For example, look at the below data.
Let us apply the date and time format to these cells to see the results. The formatting code is dd-mmm-yyyy hh:mm:ss AM/PM.
We get the following result.
Let us analyze this briefly now.
The first value we had was 43689.6675 for this, we have applied the date and time format as dd-mm-yyyy hh:mm:ss AM/PM, so the result is 12-Aug-2019 04:01:12 PM.
43689 represents data in this number, and the decimal value 0.6675021991 represents time.
Example #4 – Positive And Negative Values
When dealing with numbers, positive and negative values are part of it. To differentiate between these two values by showing them with different colors is the general rule everybody follows. For example, look at the below data.
To apply a number format to these numbers and show negative red values, below is the code.
“#,###;[Red]-#,###”
If we apply this formatting code, we can see the above numbers.
Similarly, showing negative numbers in brackets is also in practice. For example, to show the negative numbers in the bracket and red color, below is the code.
“#,###;[Red](-#,###)”
We get the following result.
Example #5 – Add Suffix Words To Numbers
If we want to add suffix words along with numbers and still be able to do calculations, it is great.
If we show a person’s weight, adding the suffix word KG will add more value to the numbers. Below is the person’s weight in KG.
To show this data with the suffix word KG, apply the below formatting code.
### ” KG”
After applying the code, the weight column looks like as shown below.
Example #6 – Using Format Painter
Format Painter Excel, we can apply one cell format to another. For example, look at the below image.
The date format is DD-MM-YYYY, and the remaining cells are not formatted for the first cell. But, we can apply the format of the first cell to the remaining cells by using a format painter.
We must select the first cell, then go to the Home tab and click on Format Painter.
Now, we must click on the next cell to apply the formatting.
Now again, select the cell and apply the formatting, but this is not the smart way of using a format painter. Instead, double-click on Format Painter by selecting the cell. Once we double-click, we can apply the format to any number of cells, applying all at once.
Important Things To Remember
- The format option is used to format the data in different formats.
- We can format the date and time together.
- The Excel Format Painter is the tool used to copy one cell format to another.
Frequently Asked Questions (FAQs)
1. What are format cells in excel?
Format cells is an option used to format the values used in excel.
We can use the format cells option by clicking on
Home → Cells group → Format drop-down option → Format Cells
2. How to format data in excel?
We can format the date with simple steps;
Consider the following example. The date of birth of 3 people is in 3 different formats. Now, let us learn how to format the date such that cell range B2:B4 are in the same format.
The steps used to format date are:
• Step 1: Select cell B2.
• Step 2: Select Home → Cells group → Format drop-down option → Format Cells
• Step 3: The Format Cells tab pops up.
• Step 4: Click Date from the Category under Number tab.
• Step 5: We can select the desired option. In our example, let us select the 4th option.
As we click OK¸ we can see that the value in cell B2 is formatted.
Similarly, we can format cells in excel.
3. What are the shortcut keys to format cells in excel?
The following are some useful shortcut keys to format cells in excel:
• Ctrl+Shift+~ – General Format
• Ctrl+Shift+# – Format Date
• [email protected] – Format Time
Recommended Articles
This article is a guide to Format cells in Excel. Here, we discuss the top 6 tips to format cells, including date, time, date and time together, format painter, etc., examples, and a downloadable Excel template. You may also look at these useful functions in Excel: –
- Shortcut Key to Start New Line in Excel Cell
- Export Excel into PDF File
- How to Format Phone Numbers in Excel?
- Accounting Number Excel Format
Formatting
Excel has many ways to format and style a spreadsheet.
Why format and style your spreadsheet?
- Make it easier to read and understand
- Make it more delicate
Styling is about changing the looks of cells, such as changing colors, font, font sizes, borders, number formats, and so on.
The most used styling functions are:
- Colors
- Fonts
- Borders
- Number formats
- Grids
There are two ways to access the styling commands in Excel:
- The Ribbon
- Formatting menu, by right clicking cells
Read more about the Ribbon in the Excel overview chapter.
Styling Commands in Ribbon
The Ribbon can be expanded by clicking the arrow/caret-down icon on the right side. This gives access to more commands:
Styling Commands, Right Clicking Cells
You can also right-click on any cell to style it:
Styling commands can be accessed from both views.
Chapter summary
Formatting is used to make spreadsheets more readable. There are many ways to add styles. The most common ones are; Color, Font, Number format and Grids.
When you fill out Excel worksheets with data, no one will succeed at once, everything is beautiful and correctly filled at the first attempt.
In the process of working with the program, you always need something: modify, edit, delete, copy or move. If the entered incorrect values in a cell, naturally, we want to correct or delete ones. But even such simple task can sometimes create difficulties.
How to set the cell format in Excel?
The contents of each Excel cell consist of three elements:
- The meaning: text, numbers, dates and times, logical content, functions and formulas.
- The formats: the type and color of the borders, the type and color of the fill, the way the values are displayed.
- Comments.
All these three elements are completely independent of each other. You can specify the format of the cell and do not write anything to it, or add a note in an empty and not formatted cell.
How to change the format of cells in Excel?
To change the format of the cells, you should call the corresponding dialog box with the CTRL + 1 (or CTRL + SHIFT + F) key or from the context menu after you right-click the «Cell Format» option.
There are 6 tabs in this dialog box:
- A number. Here you specify the way the numeric values are displayed.
- The alignment. On this tab you can control the position of the text. And the text can be displayed vertically or diagonally from any angle. Also pay attention to the «Display» section. Very often, the function «Wrap Text» is used.
- Font. The specify the style design of fonts, the size and color of the text, plus the modes of modifications.
- The border. Here you define the styles and colors of the borders. The design of all tables is better done right here.
- The fill. The name of the bookmark speaks for itself. Available for formatting colors, patterns and methods of filling (for example, a gradient with a different direction of strokes).
- The protection. Here, the cell protection settings are set, that are activated only after the protection of the whole sheet.
If you did not get the desired result on the first attempt, call this dialog again to fix the cell format in Excel.
What formatting is applicable to cells in Excel?
Each cell always has some format. If there were no changes, then this is the «General» format. It is also a standard Excel format, in which:
- the numbers are aligned on the right side;
- the text is aligned on the left side;
- the font Calibri with the height of 11 points;
- the cell has no borders and background fill.
The Format Removal – is the changing to the standard «General» format (without borders and fills).
It is worth noting that the format of cells, unlike values, can not be deleted with the DELETE key.
To delete the format of cells, select ones and use the «Clear Formats» tool, which is located on the «HOME» tab in the «Editing» section.
If you want to clear not only the format, but also the values, then select the «Clear All» option from the drop-down list of the tool (eraser).
As you can see, the eraser tool is functionally flexible and allows us to make a choice of what to delete in the cells:
- the content (same as the DELETE key);
- the formats;
- notes;
- the hyperlinks.
The option «Clear all» combines all these functions.
The deleting notes
Note, as well as formats, are not deleted from the cell by pressing the DELETE key. You can delete notes in two ways:
- The eraser tool: the option «Clear notes».
- Click on the cell with the note with the right mouse button, and from the appeared context menu select the option «Delete note».
The notation. The second way is more convenient. If you delete several notes at the same time, you must first select all of its cells.
If you used Excel in any shape or form, there is a pretty good chance that you’ve used the formatting and number formatting features. Formatting options like number, currency, percentage, date and time values are easily accessible to users. However, that’s not all there is in the world of text and number formatting. Going down the rabbit hole, custom formatting can help you fully configure Excel’s built-in settings for formatting.
The main advantage of this approach is that you can alter the look of your data without changing the actual values. This means that you do not need to use additional spaces or formulas to create the layout you want and preserve the raw data.
If you want to modify your data anyways, or need to change a value inside a formula, you can use the TEXT function with all custom formatting syntax we are going to cover in this article. It should be noted that the TEXT function returns a text, and the return value cannot be used in mathematical calculations. If you do, you will receive a #VALUE! error. In this article we’re going to be using a workbook template. You can download it below.
How to create a custom number format in Excel
- Select the cell to be formatted and press Ctrl+1 to open the Format Cells dialog. An alternative way to do is by right-clicking the cell and then going to Format Cells > Number Tab.
- Under Category, select Custom.
- Type in the format code into the Type
- Click OK to save your changes.
Note: In Format Cells dialog you can modify the built-in format codes by selecting the format you want to modify in its own category (i.e. Currency > ($1,234.10)) and then selecting Custom Category. Don’t worry, Excel will not let you delete built-in formats.
Basics
Syntax
The format code has 4 sections separated by semicolons.
POSITIVE; NEGATIVE; ZERO; TEXT
These sections are optional,
- If a code contains only 1 section, the format is applied to all number types — positive, negative and zero.
- If a code contains 2 sections, the first section is used for positive and zero values, while the second section is applied to negative values.
- If a code contains 3 sections, the first is for positive, the second is for negative, and the third is for zero.
- A code only affects text values if all sections exist.
Default format type in Excel is called General. You can type General for sections you don’t want formatted. Make sure you use a minus sign (-) with General if you want to skip negative values.
If you want to completely hide a type, leave it blank after the semicolon. For example; to hide 0 values, General;-General;;General
Placeholders and the Cheat Sheet
Placeholder | Description | Raw Value | Format Code | Formatted Value |
General | Default format | 1234.567 | General | 1234.567 |
# | Placeholder for digits (numbers) and does not add any leading zeroes. | 1234.567 | #####.#### | 1234.567 |
0 | Placeholder for digits (numbers) and add any leading zeroes. | 1234.567 | 00000.0000 | 01234.5670 |
? | Placeholder for digits (numbers) and add space characters. | 1234.567 | ?????.???? | 1234.567 |
. | Placeholder for the decimal place. | 1234.567 | 0.00 | 1234.57 |
_ | Adds a blank space, to the width of the following character. You can use in combination with parentheses to add left and right indents, _( and _) respectively. | 99 | _(#_);(#) | 99 |
-25 | (25) | |||
58 | 58 | |||
12 | 12 | |||
-71 | (71) | |||
36 | 36 | |||
* | Repeats the character after asterisk until the width of the cell is filled. | 66 | 0 *! | 66 !!!!!!!!!!!!!!! |
Full Name | @ *_ | Full Name ____ | ||
% | Convert value to a percentage with % sign | 0.12 | % | 12% |
, | Thousands separator | 1234.567 | #, | 1 |
12345678 | #, | 12,346 | ||
12345678 | #,###, | 12,346 | ||
12345678 | #,, | 12 | ||
E | Scientific notation format. Requires a ‘+’ symbol after, and a digit placeholder before and after. | 1234.567 | 0.00E+00 | 1.23E+03 |
/ | Represents fractions | 1.234 | # ##/## | 1 11/47 |
1.234 | # 000/000 | 1 117/500 | ||
1.234 | ##/## | 58/47 | ||
«» | Text placeholder for multiple characters | 1234.567 | #,##0 «km/h» | 1,235 km/h |
Good | «Result is: «@ | Result is: Good | ||
Text placeholder for single character | 1234 | #.00, K | 1.23 K | |
1234567 | #.00,, M | 1.23 M | ||
@ | Placeholder for text | Bad | «Result is: «@ | Result is: Bad |
[color] | Change Color of value. Options: [Black], [Green], [White], [Blue], [Magenta], [Yellow], [Cyan], [Red] | 1234.567 | [Green]#,##0.00_); [Red](#,##0.00); [Blue]0.00_); [Magenta]@ |
1,234.57 |
-1234.567 | (1,234.57) | |||
0 | 0.00 | |||
This is a text | This is a text |
Common Practices
Display and control of the first digit and decimals
Decimal places in the code are indicated with a period (.). Number of zeroes after the period (.) define the number of decimal places. For example,
- 0 — display 1 decimal place
- 00 — display 2 decimal places
If the number has more decimals than the decimal placeholders defined, the number will be rounded to the nearest number of placeholders.
Raw Value | Format Code | Formatted Value |
123.4 | 0.0 | 123.4 |
123.4 | 0.00 | 123.40 |
123.45 | 0.00 | 123.45 |
123.45 | 0.00 | 123.46 |
123.456 | 0.0 | 123.5 |
Alternatively, hash (#) and question mark (?) symbols can be used as decimal places. However, because any missing decimal places will be filled with zeroes, using zeroes instead will be easier to read.
Raw Value | Format Code | Formatted Value |
0.25 | 0.00 | 0.25 |
0.25 | #.## | .25 |
123 | 0.00 | 123.0 |
123 | #.?? | 123.00 |
123 | #.## | 123. |
Add text to numbers
Custom text can be added to the beginning or the end of a value. Text and characters should be added inside quotes («») and backslashes (). You can use backslash () to add single character.
Raw Value | Format Code | Formatted Value |
123.4 | 0.0 «ft.» | 123.4 ft. |
123.4 | 0.00 l | 123.40 l |
123.45 | «Approx.» 0 | Approx. 123 |
123.45 | «Result:» 0.00 C | Result: 123.46 C |
Bad | «Result is: «@ | Result is: Bad |
Quotation marks or backslashes are not necessary for spaces ( ) and some special characters.
Symbol | Description |
+ and — | Plus and minus signs |
( ) | Left and right parenthesis |
: | Colon |
^ | Caret |
‘ | Apostrophe |
{ } | Curly brackets |
< > | Less-than and greater than signs |
= | Equal sign |
/ | Forward slash |
! | Exclamation point |
& | Ampersand |
~ | Tilde |
Space character |
Below are some special characters you can use by copying or typing in the numerical code while pressing down Alt button.
Symbol | Code | Description |
™ | Alt+0153 | Trademark |
© | Alt+0169 | Copyright symbol |
° | Alt+0176 | Degree symbol |
± | Alt+0177 | Plus-Minus sign |
µ | Alt+0181 | Micro sign |
Hide value
If you leave any number of sections blank, the value of those sections will be hidden. A section should always be separated (defined) by a semicolon (;). Here are some examples,
Raw Value | Format Code | Formatted Value |
1 | 0;;0; | 1 |
-2 | 0;;0; | |
0 | 0;;0; | 0 |
Some text | 0;;0; | |
1 | ;(0);;@ | |
-2 | ;(0);;@ | (2) |
0 | ;(0);;@ | |
Some text | ;(0);;@ | Some Text |
1 | ;;; | |
-2 | ;;; | |
0 | ;;; | |
Some text | ;;; |
Replace zeroes with dashes
Zeroes can make data tables look more complicated than they actually are. You can hide them completely by using the previous method, or replace them with any character of your choice. Dash (-) is a common example. All you need to is place a dash into the ‘Zero section’.
Raw Value | Format Code | Formatted Value |
0 | General;-General;»-«;General | — |
3487 | General;-General;»-«;»-« | — |
12 | #,##0.00;(#,##0.00);»-«; | — |
Start with zeroes
If try to enter a ZIP number that starts with 0, the leading zeroes will be removed automatically by Excel. To keep the leading zeros, use zero (0) placeholder for whole numbers.
Raw Value | Format Code | Formatted Value |
10010 | 00000 | 10010 |
3487 | 00000 | 03487 |
12 | 00000 | 00012 |
0 | 00000 | 00000 |
123456 | 00000 | 123456 |
Dealing with thousands, millions, and more
You may have noticed that ‘0.0’ or other simple formats do not separate thousands or millions. Adding a comma into the code will insert commas to separate numbers.
Raw Value | Format Code | Formatted Value |
1234 | #,##0 | 1,234 |
123456 | #,##0 | 123,456 |
12345678 | #,##0 | 12,345,678 |
123456.789 | #,##0 | 123,457 |
123456.789 | #,##0.0 | 123,456.8 |
There must be placeholders for numbers smaller than one thousand, otherwise such values will be hidden. This behavior allows us to round and format our value to show only thousands or millions.
Raw Value | Format Code | Formatted Value |
1234 | #, | 1 |
123456 | #, | 123 |
12345678 | #, | 12345 |
12345678 | #,, | 12 |
123456 | #.0, K | 123.5 K |
12345678 | #.0,, M | 12.3 M |
Display numbers as phone numbers
Phone numbers can be hard to read without any separators. Custom Number Format Codes is perfect for this job. The hash (#) character should be your best bet to avoid any redundancy of placeholders (0, ?)
Raw Value | Format Code | Formatted Value |
1234567890 | (###) ###-#### | (123) 456-7890 |
12345678900 | (###) #### #### | (123) 4567 8900 |
1234567890 | (##) #### #### | (12) 3456 7890 |
Showing Month and Weekday Names
Date and time values are stored as numbers in Excel. When you enter a date, Excel automatically converts it into a numerical value, and then formats the cell.
Before jumping into the code, let’s review some basics. Formatting code has special placeholders for date and time formatting that behave a bit differently. For example, while m and mm will show month as a number, mmm and mmmm will show as a text string. Below are some examples.
Raw Value | Format Code | Formatted Value |
4/1/2018 | m | 4 |
4/1/2018 | mm | 04 |
4/1/2018 | mmm | Apr |
4/1/2018 | mmmm | April |
4/1/2018 | mmmmm | A |
4/1/2018 | d | 1 |
4/1/2018 | dd | 01 |
4/1/2018 | ddd | Sun |
4/1/2018 | dddd | Sunday |
4/1/2018 11:59:31 PM | dddd, mmmm dd, yyyy h:mm AM/PM;@ | Sunday, April 01, 2018 11:59 PM |
Here is the full list of options for the date 4/1/2018 23:59:31 ,
Format Code | Description | Example (4/1/2018 23:59:31) |
yyyy | Displays the year as a four-digit number. | 2018 |
yy | Displays the year as a two-digit number. | 18 |
m | Displays the month as a number without a leading zero. | 4 |
mm | Displays the month with a leading zero. | 04 |
mmm | Displays the month as text, as an abbreviation. | Apr |
mmmm | Displays the month as text. | April |
mmmmm | Displays the month as a single character | A |
d | Displays the day as a number, without a leading zero. | 1 |
dd | Displays the day as a number, with a leading zero. | 01 |
ddd | Displays the day as a day of the week, as an abbreviation. | Sun |
dddd | Displays the day as a day of the week, without abbreviation | Sunday |
h | Displays the hour without a leading zero. | 23 |
hh | Displays the hour with a leading zero. | 23 |
[h] | Displays elapsed time in hours (to be used when the time value exceeds 24 hours). | 1036607 |
m | Displays the minute without a leading zero. | 4 |
mm | Displays the minute with a leading zero. | 04 |
[m] | Displays elapsed time in minutes (to be used when the time value exceeds 60 minutes). | 62196479 |
s | Displays the second without a leading zero. | 31 |
ss | with a leading zero. | 31 |
[s] | Displays elapsed time in seconds (to be used when the time value exceeds 60 seconds). | 3731788771 |
AM/PM | Converts to 12-hour time. Displays either AM/am/A/a or PM/pm/P/p depending on the time of day. | PM |
am/pm | pm | |
A/P | P | |
a/p | p |
Come in Colors Everywhere
Number Formatting can be used color sections of a code. A common example is using the color red for negative numbers. Color code must be placed inside square brackets (i.e. [color]), and entered at the beginning of a section. Here are some available colors,
- [Black]
- [Blue]
- [Cyan]
- [Green]
- [Magenta]
- [Red]
- [White]
- [Yellow]
Raw Value | Format Code | Formatted Value |
1234.567 | [Green]#,##0.00_);[Red](#,##0.00);[Blue]0.00);[Magenta]@ | 1,234.57 |
-1234.567 | (1,234.57) | |
0 | 0.00 | |
This is a text | This is a text |
Conditions
Although Excel has conditional formatting menu, basic conditions can be applied through code. Condition should be placed inside square brackets (i.e. [condition]) just like colors. Conditions are similar to the conditions in some functions (i.e. SUMIF). First add a logical operator, and then a value. For example, “[>=1000000]” means “if value of cell is greater than or equal to 1,000,000 apply the following format”. Conditions should come before the actual code, again, just like with colors. If you want to a color as well, the color code should come first.
Another important thing to note here is, that section structure changes from Positive, Negative, Zero, Text to First Condition, Second Condition (if exists), if previous conditions are not applied. There should be at least two sections for conditions.
If you enter only one condition code and then save the format, Excel will automatically add the second section with «;General». This means that if the condition is not met, General format will be used.
Raw Value | Format Code | Formatted Value |
1234567890 | [>=1000000]#,##0,,»M»;[>=1000]#,##0,»K»;0 | 1,235M |
12345 | 12K | |
1 | [=1]0″ apple»;0″ apples» | 1 apple |
10 | 10 apples | |
25 | [Green][>=85]»PASSED»;[Blue][>=60]»RE-CHECK»;[Red]»FAILED» | FAILED |
72 | RE-CHECK | |
91 | PASSED |
Introduction
Number formats control how numbers are displayed in Excel. The key benefit of number formats is that they change how a number looks without changing any data. They are a great way to save time in Excel because they perform a huge amount of formatting automatically. As a bonus, they make worksheets look more consistent and professional.
Video: What is a number format
What can you do with custom number formats?
Custom number formats can control the display of numbers, dates, times, fractions, percentages, and other numeric values. Using custom formats, you can do things like format dates to show month names only, format large numbers in millions or thousands, and display negative numbers in red.
Where can you use custom number formats?
Many areas in Excel support number formats. You can use them in tables, charts, pivot tables, formulas, and directly on the worksheet.
- Worksheet — format cells dialog
- Pivot Tables — via value field settings
- Charts — data labels and axis options
- Formulas — via the TEXT function
What is a number format?
A number format is a special code to control how a value is displayed in Excel. For example, the table below shows 7 different number formats applied to the same date, January 1, 2019:
Input | Code | Result |
---|---|---|
1-Jan-2019 | yyyy | 2019 |
1-Jan-2019 | yy | 19 |
1-Jan-2019 | mmm | Jan |
1-Jan-2019 | mmmm | January |
1-Jan-2019 | d | 1 |
1-Jan-2019 | ddd | Tue |
1-Jan-2019 | dddd | Tuesday |
The key thing to understand is that number formats change the way numeric values are displayed, but they do not change the actual values.
Where can you find number formats?
On the home tab of the ribbon, you’ll find a menu of build-in number formats. Below this menu to the right, there is a small button to access all number formats, including custom formats:
This button opens the Format Cells dialog box. You’ll find a complete list of number formats, organized by category, on the Number tab:
Note: you can open Format Cells dialog box with the keyboard shortcut Control + 1.
General is default
By default, cells start with the General format applied. The display of numbers using the General number format is somewhat «fluid». Excel will display as many decimal places as space allows, and will round decimals and use scientific number format when space is limited. The screen below shows the same values in column B and D, but D is narrower and Excel makes adjustments on the fly.
How to change number formats
You can select standard number formats (General, Number, Currency, Accounting, Short Date, Long Date, Time, Percentage, Fraction, Scientific, Text) on the home tab of the ribbon using the Number Format menu.
Note: As you enter data, Excel will sometimes change number formats automatically. For example if you enter a valid date, Excel will change to «Date» format. If you enter a percentage like 5%, Excel will change to Percentage, and so on.
Shortcuts for number formats
Excel provides a number of keyboard shortcuts for some common formats:
Format | Shortcut |
---|---|
General format | Ctrl Shift ~ |
Currency format | Ctrl Shift $ |
Percentage format | Ctrl Shift % |
Scientific format | Ctrl Shift ^ |
Date format | Ctrl Shift # |
Time format | Ctrl Shift @ |
Custom formats | Control + 1 |
See also: 222 Excel Shortcuts for Windows and Mac
Where to enter custom formats
At the bottom of the predefined formats, you’ll see a category called custom. The Custom category shows a list of codes you can use for custom number formats, along with an input area to enter codes manually in various combinations.
When you select a code from the list, you’ll see it appear in the Type input box. Here you can modify existing custom code, or to enter your own codes from scratch. Excel will show a small preview of the code applied to the first selected value above the input area.
Note: Custom number formats live in a workbook, not in Excel generally. If you copy a value formatted with a custom format from one workbook to another, the custom number format will be transferred into the workbook along with the value.
How to create a custom number format
To create custom number format follow this simple 4-step process:
- Select cell(s) with values you want to format
- Control + 1 > Numbers > Custom
- Enter codes and watch preview area to see result
- Press OK to save and apply
Tip: if you want base your custom format on an existing format, first apply the base format, then click the «Custom» category and edit codes as you like.
How to edit a custom number format
You can’t really edit a custom number format per se. When you change an existing custom number format, a new format is created and will appear in the list in the Custom category. You can use the Delete button to delete custom formats you no longer need.
Warning: there is no «undo» after deleting a custom number format!
Structure and Reference
Excel custom number formats have a specific structure. Each number format can have up to four sections, separated with semi-colons as follows:
This structure can make custom number formats look overwhelmingly complex. To read a custom number format, learn to spot the semi-colons and mentally parse the code into these sections:
- Positive values
- Negative values
- Zero values
- Text values
Not all sections required
Although a number format can include up to four sections, only one section is required. By default, the first section applies to positive numbers, the second section applies to negative numbers, the third section applies to zero values, and the fourth section applies to text.
- When only one format is provided, Excel will use that format for all values.
- If you provide a number format with just two sections, the first section is used for positive numbers and zeros, and the second section is used for negative numbers.
- To skip a section, include a semi-colon in the proper location, but don’t specify a format code.
Characters that display natively
Some characters appear normally in a number format, while others require special handling. The following characters can be used without any special handling:
Character | Comment |
---|---|
$ | Dollar |
+- | Plus, minus |
() | Parentheses |
{} | Curly braces |
<> | Less than, greater than |
= | Equal |
: | Colon |
^ | Caret |
‘ | Apostrophe |
/ | Forward slash |
! | Exclamation point |
& | Ampersand |
~ | Tilde |
Space character |
Escaping characters
Some characters won’t work correctly in a custom number format without being escaped. For example, the asterisk (*), hash (#), and percent (%) characters can’t be used directly in a custom number format – they won’t appear in the result. The escape character in custom number formats is the backslash (). By placing the backslash before the character, you can use them in custom number formats:
Value | Code | Result |
---|---|---|
100 | #0 | #100 |
100 | *0 | *100 |
100 | %0 | %100 |
Placeholders
Certain characters have special meaning in custom number format codes. The following characters are key building blocks:
Character | Purpose |
---|---|
0 | Display insignificant zeros |
# | Display significant digits |
? | Display aligned decimals |
. | Decimal point |
, | Thousands separator |
* | Repeat following character |
_ | Add space |
@ | Placeholder for text |
Zero (0) is used to force the display of insignificant zeros when a number has fewer digits than zeros in the format. For example, the custom format 0.00 will display zero as 0.00, 1.1 as 1.10 and .5 as 0.50.
Pound sign (#) is a placeholder for optional digits. When a number has fewer digits than # symbols in the format, nothing will be displayed. For example, the custom format #.## will display 1.15 as 1.15 and 1.1 as 1.1.
Question mark (?) is used to align digits. When a question mark occupies a place not needed in a number, a space will be added to maintain visual alignment.
Period (.) is a placeholder for the decimal point in a number. When a period is used in a custom number format, it will always be displayed, regardless of whether the number contains decimal values.
Comma (,) is a placeholder for the thousands separators in the number being displayed. It can be used to define the behavior of digits in relation to the thousands or millions digits.
Asterisk (*) is used to repeat characters. The character immediately following an asterisk will be repeated to fill remaining space in a cell.
Underscore (_) is used to add space in a number format. The character immediately following an underscore character controls how much space to add. A common use of the underscore character is to add space to align positive and negative values when a number format is adding parentheses to negative numbers only. For example, the number format «0_);(0)» is adding a bit of space to the right of positive numbers so that they stay aligned with negative numbers, which are enclosed in parentheses.
At (@) — placeholder for text. For example, the following number format will display text values in blue:
0;0;0;[Blue]@
See below for more information about using color.
Automatic rounding
It’s important to understand that Excel will perform «visual rounding» with all custom number formats. When a number has more digits than placeholders on the right side of the decimal point, the number is rounded to the number of placeholders. When a number has more digits than placeholders on the left side of the decimal point, extra digits are displayed. This is a visual effect only; actual values are not modified.
Number formats for TEXT
To display both text along with numbers, enclose the text in double quotes («»). You can use this approach to append or prepend text strings in a custom number format, as shown in the table below.
Value | Code | Result |
---|---|---|
10 | General» units» | 10 units |
10 | 0.0″ units» | 10.0 units |
5.5 | 0.0″ feet» | 5.5 feet |
30000 | 0″ feet» | 30000 feet |
95.2 | «Score: «0.0 | Score: 95.2 |
1-Jun | «Date: «mmmm d | Date: June 1 |
Number formats for DATES
Dates in Excel are just numbers, so you can use custom number formats to change the way they display. Excel has many specific codes you can use to display components of a date in different ways. The screen below shows how Excel displays the date in D5, September 3, 2018, with a variety of custom number formats:
Number formats for TIME
Times in Excel are fractional parts of a day. For example, 12:00 PM is 0.5, and 6:00 PM is 0.75. You can use the following codes in custom time formats to display components of a time in different ways. The screen below shows how Excel displays the time in D5, 9:35:07 AM, with a variety of custom number formats:
Note: m and mm can’t be used alone in a custom number format since they conflict with the month number code in date format codes.
Number formats for ELAPSED TIME
Elapsed time is a special case and needs special handling. By using square brackets, Excel provides a special way to display elapsed hours, minutes, and seconds. The following screen shows how Excel displays elapsed time based on the value in D5, which represents 1.25 days:
Number formats for COLORS
Excel provides basic support for colors in custom number formats. The following 8 colors can be specified by name in a number format: [black] [white] [red][green] [blue] [yellow] [magenta] [cyan]. Color names must appear in brackets.
Colors by index
In addition to color names, it’s also possible to specify colors by an index number (Color1,Color2,Color3, etc.) The examples below are using the custom number format: [ColorX]0″▲▼», where X is a number between 1-56:
[Color1]0"▲▼" // black
[Color2]0"▲▼" // white
[Color3]0"▲▼" // red
[Color4]0"▲▼" // green
etc.
The triangle symbols have been added only to make the colors easier to see. The first image shows all 56 colors on a standard white background. The second image shows the same colors on a gray background. Note the first 8 colors shown correspond to the named color list above.
Apply number formats in a formula
Although most number formats are applied directly to cells in a worksheet, you can also apply number formats inside a formula with the TEXT function. For example, with a valid date in A1, the following formula will display the month name only:
=TEXT(A1,"mmmm")
The result of the TEXT function is always text, so you are free to concatenate the result of TEXT to other strings:
="The contract expires in "&TEXT(A1,"mmmm")
The screen below shows the number formats in column C being applied to numbers in column B using the TEXT function:
One quirk of the TEXT function relates to double quotes («») that are part of certain custom number formats. Because the format_text is entered as a text string, Excel won’t allow you to enter the formula without removing the quotes or adding more quotes. For example, to display a large number in thousands, you can use a custom number format like this:
0, "k"
Notice k appears in quotes («k»). To apply the same format with the TEXT function, you can use simply:
=TEXT(A1,"0, k")
Notice the k is not surrounded by quotes. Alternately, you can add extra double quotes as below, which returns the same result:
=TEXT(A1,"0,""K""")
This behavior only occurs when you are hardcoding a format inside TEXT. If you are applying a format entered elsewhere on the worksheet (as in cells C6 and C9 in the worksheet above) you can use a standard number format.
Measurements
You can use a custom number format to display numbers with an inches mark («) or a feet mark (‘). In the screen below, the number formats used for inches and feet are:
0.00 ' // feet
0.00 " // inches
These results are simplistic, and can’t be combined in a single number format. You can however use a formula to display feet together with inches.
Conditionals
Custom number formats also up to two conditions, which are written in square brackets like [>100] or [<=100]. When you use conditionals in custom number formats, you override the standard [positive];[negative];[zero];[text] structure. For example, to display values below 100 in red, you can use:
[Red][<100]0;0
To display values greater than or equal to 100 in blue, you can extend the format like this:
[Red][<100]0;[Blue][>=100]0
To apply more than two conditions, or to change other cell attributes, like fill color, etc. you’ll need to switch to Conditional Formatting, which can apply formatting with much more power and flexibility using formulas.
Plural text labels
You can use conditionals to add an «s» to labels greater than zero with a custom format like this:
[=1]0″ day»;0″ days»
Telephone numbers
Custom number formats can also be used for telephone numbers, as shown in the screen below:
Notice the third and fourth examples use a conditional format to check for numbers that contain an area code. If you have data that contains phone numbers with hard-coded punctuation (parentheses, hyphens, etc.) you will need to clean the telephone numbers first so that they only contain numbers.
Hide all content
You can actually use a custom number format to hide all content in a cell. The code is simply three semi-colons and nothing else ;;;
To reveal the content again, you can use the keyboard shortcut Control + Shift + ~, which applies the General format.
Other resources
- Developer Bryan Braun built a nice interactive tool for building custom number formats