Professional Documents
Culture Documents
The tutorial demonstrates different techniques to quickly merge two cells in Excel and combine
multiple cells without losing data in Excel 2016, 2013, 2010 and lower.
In your Excel worksheets, you may often need to merge two or more cells into one large cell.
For example, you may want to combine several cells for a better data presentation or structure.
In other cases, there may be too much content to be displayed in one cell, and you decide to
merge it with adjacent blank cells.
Whatever the reason, combining cells in Excel is not as straightforward as it may seem. If at
least two cells you are trying to join contain data, the standard Excel Merge Cells feature will
only keep the upper-left cell value and discard values in other cells.
But is there a way to merge cells in Excel without losing data? Of course there is. And further on
in this tutorial, you will find a few solutions that work in all versions of Excel 2016, Excel 2013,
Excel 2010 and lower.
In this example, we have a list of fruits in cell A1 and we want to merge it with a couple of empty
cells to the right (B2 and C2) to create a large cell that fits the entire list.
Once you click Merge and Center, the selected cells will be combined into one cell and the text
is centered like in the following screenshot:
Merge Cells - join the selected cells into a single cell without centering the text:
Tip. To change the text alignment after merging, simply select the merged cell and click the
desired alignment in the Alignment group on the Home tab.
Excel's merging features - limitations and specificities
When using Excel's built-in features to combine cells, there are a few things to keep in mind:
1.
Make sure that all the data you want to include in a merged cell is entered in the leftmost cellof the selected range because only the content of the upper-left cell will survive
after merging, data in all other cells will be deleted. If you are looking to combine two or
more cells with data in them, check out How to merge cells without losing data.
2.
If the Merge and Center button is greyed out, most likely the selected cells are
in Edit mode. Press the Enter key to cancel the Edit mode, and then try to merge cells.
3.
None of standard Excel merging options works for the cells inside an Excel table. You
have to convert a table to a usual range first (right click the table and select Table > Convert
to Rangefrom the context menu), and then combine the cells.
4.
It's not possible to sort a range containing both merged and unmerged cells.
On the Home tab, in the Editing group, click Fill > This will move the contents of the
selected cells to the top-most cell.
Click Merge and Center or Merge Cells, depending on whether you want the merged text
to be centered or not.
If the combined values spread across two or more rows, make the column a bit wider and
repeat the process.
This merging technique is easy to use, however it does have a number of limitations:
Method 2. Merge multiple cells with data in any range (Merge Cells add-in)
To be able to merge two or more cells in Excel without losing data and without extra "tricks",
we created a special tool - Merge Cells for Excel.
Using this add-in, you can quickly combine multiple cells containing any data types including
text, numbers, dates and special symbols. Also, you can separate the values with any delimiter
of your choosing such as a comma, space, slash or line break.
To join cells exactly the way you want them, configure the following options:
Apart from joining cells, this tool can quickly merge rows and columns, you just have to select
the corresponding option in the "What to merge" drop-down list.
To give the Merge Cells add-in a try, you are welcome to download the evaluation version that
works with Excel 2016, 2013, 2010, 2007 and 2003.
Method 3. Use the CONCATENATE function to combine two or multiple cells
Users who feel more comfortable with Excel formulas, may like this way to combine cells in
Excel. You can employ the CONCATENATE function or Excel & operator to join the cells' values
first, and then merge the cells if needed. The detailed steps follow below.
Supposing you want to combine two cells in your Excel sheet, A2 and B2, and both cells have
data in them. Not to lose the value in the second cell during merging, concatenate the two cells
by using either of the following formulas:
=CONCATENATE(A2,", ",B2)
=A2&", "&B2
The formula, however, inserts the concatenated values in another cell. If you do need to merge
two cells with the original data, A2 and B2 in this example, then a few extra steps are required:
You can find more formula examples in the following tutorial - CONCATENATE in Excel:
combine text strings, cells and columns.
Shortcut for merging cells in Excel
If you merge cells in your Excel worksheets on a regular basis, you may find useful the
followingMerge Cells shortcut.
1.
2.
At first sight, the merge shortcut seems a bit long-winded, but with a little practice you may find
this way to combine cells faster than clicking the Merge and Center button with the mouse.
How to quickly find merged cells
To find merged cells in your Excel sheet, perform the following steps:
1.
2.
Press Ctrl + F to open the Find and Replace dialog, or click Find & Select > Find.
On the Find tab, click Options > Format.
3.
On the Alignment tab, select the Merge cells box under Text control, and click OK.
4.
Finally, click either Find Next to select the next merged cell, or Find All to find all
merged cells on the sheet. If you choose the latter, Microsoft Excel will display a list of all
found merged cells and let you navigate between them by selecting one of the merged cells
in this list:
After unmerging the cells, the entire contents will appear in the top-left cell.
Select the cells that you'd like to join, B4 and C4 in this example.
Press Ctrl + 1 to open the Format Cells
Switch to the Alignment tab and select the Center Across Selection option from
the Horizontaldrop-down list, and then click OK.
To prove that we did not really merge two cells, we can select each one individually:
This is how you can combine two cells in Excel or merge multiple cells without losing data.
Hopefully, this information has proved useful for your day-to-day tasks. I thank you for reading
and hope to see on our blog next week.
Merge cells
Concatenate cells' values
When you merge cells, you "physically" merge two or more cells into a single cell. As a result,
you have one larger cell that is displayed across multiple rows and/or columns in your
worksheet.
When you concatenate cells in Excel, you combine only the contents of those cells. In other
words, concatenation in Excel is the process of joining two or more values together. This
method is often used to combine a few pieces of text that reside in different cells (technically,
these are called text strings or simply strings) or insert a formula-calculated value in the middle
of some text.
The following screenshot demonstrates the difference between these two methods:
Merging cells in Excel is the subject of our next article, and in this tutorial we will tackle two
essential ways to concatenate strings in Excel - by using the CONCATENATE function and the
Excel& operator.
Excel CONCATENATE function
The CONCATENATE function in Excel is designed to join different pieces of text together or
combine values from several cells into one cell.
The syntax of Excel CONCATENATE is as follows:
CONCATENATE(text1, [text2], )
Where text is a text string, cell reference or formula-driven value.
Below you will find a few examples of using the CONCATENATE function in Excel.
Concatenating the values of several cells
The simplest CONCATENATE formula to combine the values of cells A1 and B1 is as follows:
=CONCATENATE(A1, B1)
Please note that the values will be knit together without any delimiter, as in row 2 in the
screenshot below.
To separate the values with a space, enter " " in the second argument, as in row 3 in the
screenshot below.
To separate the concatenated values with other delimiters such as a comma, space or slash,
please see Excel CONCATENATE formulas with special characters.
Concatenating a text string and cell value
There is no reason for the Excel CONCATENATE function to be limited to only joining cells'
values. You can also use it to concatenate various text strings to make the result more
meaningful. For example:
=CONCATENATE(A1, " ", B1, " completed")
The above formula informs the user that a certain project is completed, as in row 2 in the
screenshot below. Please notice that we add a space before the word " completed" to separate
the concatenated text strings.
Naturally, you can add a text string in the beginning or in the middle of your Concatenate
formula as well:
=CONCATENATE("See ", A1, " ", B1)
A space (" ") is added in between the combined values, so that the result displays as "Project 1"
rather than "Project1".
As demonstrated in the screenshot below, the CONCATENATE function and "&" operator return
identical results:
On Windows, use CHAR(10) where 10 is the ASCII code for Line feed.
On the Mac system, use CHAR(13) where 13 is the ASCII code for Carriage return.
In this example, we have the address pieces in columns A through F, and we are putting them
together in column G by using the concatenation operator "&". The merged values are
separated with a comma (", "), space (" ") and a line break CHAR(10):
=A2 & " " & B2 & CHAR(10) & C2 & CHAR(10) & D2 & ", " & E2 & " " & F2
Note. When using line breaks to separate the concatenated values, you must have the "Wrap
text" option enabled for the result to display correctly. To do this, press Ctrl + 1 to open
theFormat Cells dialog, switch to the Alignment tab and check the Wrap text box.
In the same manner, you can separate concatenated strings with other characters such as:
Tip. A quick way to copy the formula down to other cells in the column is to select the cell with
the formula and double-click the fill handle.
Please note that Microsoft Excel determines how far to copy cells after the fill handle double
click based on the cells referred to by your formula. If there happen to be empty cells in your
table, say cell A6 and B6 were blank in this example, the formula would be copied up to row 5
only. In this case, you would need to drag the fill handle down manually to concatenate the
entire columns.
An alternative way to concatenate columns in Excel is to use the corresponding option of
theMerge Cells add-in.
Note. When using this method you must click each individual cell. Selecting a range with the
mouse would add an array to the formula, which the CONCATENATE function does not accept.
Select the cell where you want to output the concatenated range.
Enter the TRANSPOSE formula in that cell, =TRANSPOSE(A1:A10) in this example.
In the formula bar, press F9 to replace the formula with calculated values.
Delete the curly braces that turn a usual Excel formula into an array formula. As a result,
you will have all the cells references to be included in your concatenation formula.
Type =CONCATENATE( in front of the cell references in the formula bar, type the closing
parenthesis and press Enter.
Note. Whichever method you use, the concatenated value in C1 is a text string (notice its leftalignment in the cell), although each of the original values is a number. This is because the
CONCATENATE function always returns a text string regardless of the source data type.
Method 3. Use the Merge Cells add-in
A quick and formula-free way to concatenate any range in Excel is to use the Merge Cells addin for Excel with the "Merge all areas in selection" option turned off, as demonstrated
in Combine the values of several cells into one cell.
Concatenate numbers and dates in various formats
When you concatenate a text string with a number or date, you may want to format the result
differently depending on your dataset. To do this, embed the TEXT function in your Excel
concatenate formula.
The TEXT(value, format_text) function has two arguments:
In the first argument (value), you supply a number or date to be converted to text, or a
reference to the cell containing a numeric value.
In the second argument (format_text), you enter the desired format using the codes that
the TEXT function can understand.
We have already discussed one such formula in the beginning of this tutorial
- CONCATENATE / TEXT formula that returns the current date concatenated with a text string.
A few more formula examples that concatenate a text value and a number follow below:
=A2 & " " & TEXT(B2, "$#,#0.00") - display the number with 2 decimal places and the $ sign.
=A2 & " " & TEXT(B2, "0.#") - does not display extra zeros and the $ sign.
=A2 & " " & TEXT(B2, "# ?/???") - display the number as a fraction.
and hit the Merge button. The result may look similar to this:
To check how the Merge Cells add-in will cope with your data sets, you are welcome
to download a fully functional trial version. And if you are happy with the result, you may want to
buy helpful tool as a separate product or as part of our Ultimate Suite for Excel, which includes
40+ other time-saving tools for most common Excel tasks. Either way, we will happily offer you
the 15 off coupon code that we've created especially for our blog readers: AB14-BlogSpo.
If someone wants to examine the formulas discussed in this tutorial more closely, the Sample
workbook with concatenation formulas is available for download. Thank you for reading!
o
o
o
Select a cell, a range of cells, or an entire column, and press Ctrl + 1 to open the Format
Cellsdialog. Alternatively, you can right click the cell(s) and select Format Cells from the
context menu.
2.
On the Number tab of the Format Cells window, switch to
either General or Number underCategory, and then click the OK button to convert the time
Note. In Microsoft Excel system, times are stored as fractional parts of decimal numbers, that is
why the integer part of the converted time always equals 0, like demonstrated in the screenshot
above. If in your worksheet, the integer part is any number other than zero, it means that your
cells contain both dates and times.
To do the opposite, i.e. to convert a decimal to time in Excel, simply apply one of time formats
to the cell(s).
Functions and calculations to convert time to hours, minutes or seconds
In Microsoft Excel, to convert time to a total number of hours, minutes or seconds, you can use
either:
Simple arithmetic calculations, i.e. multiply the time value by the number of hours,
minutes or seconds in one day, or
Time functions, such as HOUR, MINUTE and SECOND.
Converting time to hours in Excel
The simplest arithmetic calculation to convert time to hours in Excel is multiplying time by 24,
i.e. by the number of hours in one day:
For example, if A2 contains "1:15:00", both formulas will return 75 because 1 hour and 15
minutes equates to 75 minutes.
If what you want is the number of compete minutes, use the INT function like in the previous
example:
=INT(A2*1440)
You can view the results in the screenshot below:
Tip. If any of the above formulas returns a value formatted as time, simply change the cell's
format to General to display it as a number.
To extract the time portion, subtract the date returned by the above formula from the original
date and time value:
=A2-B2
Where column A contains the original date & time values and column B contains the dates
returned by the INT function.
If you'd rather not have time values linked to the separated dates (for example, you may want to
remove the date column in the future), you can use the following MOD formula that refers to the
original data only:
=MOD(A2,1)
Tip. If the separated date and time values are not displayed properly, change the format of the
new columns to Date and Time, respectively.
This is how you split date and time in Excel. If you want to further separate hours, minutes and
seconds into individual columns, then use the HOUR, MINUTE and SECOND functions, as
demonstrated in How to get hours, minutes and seconds from a timestamp.
How to spell time in Excel
Sometimes, you may need to convert time into the format that reads something like "# days, #
hours, # minutes and # seconds". A good thing is that you already know all the ingredients of the
formula:
=INT(C4) & " days, " & HOUR(C4) & " hours, " & MINUTE(C4) & " minutes and " &
SECOND(C4) & " seconds"
If you wish to get rid of 0 values, like in cells D6 and D7 in the screenshot above, then include
the following IF statements:
=IF(INT(C4)>0, INT(C4)&" days, ","") & IF(HOUR(C4)>0, HOUR(C4) & " hours, ","") &
IF(MINUTE(C4)>0, MINUTE(C4) & " minutes and ","") & IF(SECOND(C4)>0, SECOND(C4) &
" seconds","")
All zeros are gone!
Note. When either of the above formulas refers to a negative number, the #NUM! error will
appear. This may happen when you subtract a bigger time from a smaller one.
An alternative way to write time in words in Excel is to apply the following custom time format to
the cell: d "day," h "hours," m "minutes and" s "seconds". No formulas and no calculations are
required! For more information, please see Creating a custom time format in Excel.
Convert text to time in Excel
If your time formulas and calculations do not work right, time values formatted as text is often
the cause. The fastest way to convert text to time in Excel is using the TIMEVALUE function.
The Excel TIMEVALUE function has just one argument:
TIMEVALUE(time_text)
Time_text is a text string in any of the time formats that Excel can recognize. For example:
=TIMEVALUE("6:20 PM")
=TIMEVALUE("6-Jan-2015 6:20 PM")
=TIMEVALUE(A2) where A2 contains a text string
As you see, the formulas with cell references and corresponding text strings deliver identical
results. Also, please notice the left alignment of time strings (text values) in cells A2 and A6 and
right-aligned converted time values in column D.
Convert time to text in Excel
Supposing you have an Excel file full of times formatted to look like "8:30:00 AM" and you want
to convert them to the text format. Simply changing the cell's format to TEXT won't work
because this would change your time values to underlying numeric representation of the time.
For example, 8:30:00 AM will be converted to decimal 0.354166666666667.
So, how do you convert cells to the text format so that your cells still have the time in them? The
answer is to use the TEXT function that converts a numeric value to text with the display
formatting that you specify, for example:
=TEXT($A2,"h:mm:ss")
The screenshot below demonstrates other possible formats:
That's all for today. If someone wants to get the first-hand experience with the formulas
discussed in this article, you are most welcome to download the Sample workbook for
converting time in Excel.
If you want to learn a few more helpful formulas to add and subtract times, calculate elapsed
time and time difference, please check out other parts of our Excel Times tutorial (the links are
available at the end of this page). I thank you for reading and hope to see you again next week.
Explanation
=A2-B2
=TIME(HOUR(A2), MINUTE(A2),
SECOND(A2)) - TIME(HOUR(B2),
MINUTE(B2), SECOND(B2))
Remembering that in the internal Excel system, times are represented by fractional parts of
decimal numbers, you are likely to get the results similar to this:
The decimals in column D are perfectly true but not very meaningful. To make them more
informative, you can apply custom time formatting with one of the following codes:
Time code
Explanation
h:mm
h:mm:ss
To apply the custom time format, click Ctrl + 1 to open the Format Cells dialog,
select Customfrom the Category list and type the time codes in the Type box. Please
see Creating a custom time format in Excel for the detailed steps.
And now, let's see how our time difference formula and time codes work in real worksheets.
WithStart times residing in column A and End times in column B, you can copy the following
formula in columns C though E:
=$B2-$A2
The elapsed time is displayed differently depending on the time format applied to the column:
Note. If the elapsed time is displayed as hash marks (#####), then either a cell with the formula
is not wide enough to fit the time or the result of your time calculations is a negative value.
Notes:
The value returned by the TEXT function is always text. Please notice the left alignment
of text values in columns C:E in the screenshot above. In certain scenarios, this might be a
significant limitation because you won't be able to use the returned "text times" in other
calculations.
If the result is a negative number, the TEXT formula returns the #VALUE! error.
Formula 3. Count hours, minutes or seconds between two times
To present the difference between two times in a single time unit (hours ,minutes or seconds),
you can perform the following calculations.
Calculate hours between two times:
The logic of the below formula is obvious and hardly requires any explanation :)
=(End time - Start time) * 24
Supposing that your start time is in A2 and end time in B2, you can use a simple equation B2-A2
to calculate the difference between two times, and then multiply it by 24, which is the number of
hours in one day:
=(B2-A2) * 24
To get the number of complete hours, use the INT function to round the result down to the
nearest integer:
=INT((B2-A2) * 24)
=(B2-A2)* 86400
Note. For the results to display correctly, the General format should be applied to the cells with
your time difference formula.
Formula 4. Calculate difference in one time unit ignoring others
To find the difference between 2 times in a certain time unit, ignoring the others, use one of the
following functions.
Note. If the end time is greater than the start time (i.e. the result of the formula is a negative
number), the #NUM! error is returned.
In case the elapsed time exceeds 24 hours, use one of these time formats, for example d
"days" h:mm:ss like in the following screenshot:
If your starting points contain only time values without dates, you need to use the TIME
functionto calculate the elapsed time correctly. For example, the following formula returns the
time elapsed since the time value in cell A2 up to now:
Note. The elapsed time is not updated in real-time, it refreshes only when the workbook is
reopened or recalculated. To force the formula to update, press either Shift + F9 to recalculate
the active spreadsheet or hit F9 to recalculate all open workbooks.
Formula 5. Display time difference as "XX days, XX hours, XX minutes and XX seconds"
This is probably the most user-friendly formula to calculate time difference in Excel. You use the
HOUR, MINUTE and SECOND functions to return corresponding time units and the INT
function to compute the difference in days. And then, you concatenate all these functions in a
single formula along with the text labels:
=INT(B2-A2) & " days, " & HOUR(B2-A2) & " hours, " & MINUTE(B2-A2) & " minutes and "
& SECOND(B2-A2) & " seconds"
To instruct your Excel time difference formula to hide zero values, embed four IF functions into
it:
=IF(INT(B2-A2)>0, INT(B2-A2) & " days, ","") & IF(HOUR(B2-A2)>0, HOUR(B2-A2) & "
hours, ","") & IF(MINUTE(B2-A2)>0, MINUTE(B2-A2) & " minutes and ","") &
IF(SECOND(B2-A2)>0, SECOND(B2-A2) & " seconds","")
The syntax may seem excessively complicated, but it works :)
Alternatively, you can calculate time difference by simply subtracting the start time from the end
time (e.g. =B2-A2), and then apply the following time format to the cell:
An advantage of this approach is that your result would be a normal time value that you could
use in other time calculations, while the result of the complex formula discussed above is a text
value. A drawback is that the custom time format cannot distinguish between zero and non-zero
values and ignore the latter. To display the result in other formats, please see Custom formats
for time intervals over 24 hours.
Adding and subtracting time in Excel
Basically, there are 2 ways to add and subtract time in Excel:
Using arithmetic calculations based on the number of hours (24), minutes (1440) and
seconds (86400) in one day
The TIME(hour, minute, second) function makes Excel time calculations really easy, however
it does not allow adding or subtracting more than 23 hours, or 59 minutes, or 59 seconds. If you
are working with bigger time intervals, then use one of the arithmetic calculations demonstrated
below.
How to add or subtract hours to time in Excel
To add hours to a given time in Excel, you can use one the following formulas.
TIME function to add under 24 hours
=Start time + TIME(N hours, 0, 0)
For example, if your start time is in cell A2, and you want to add 2 hours to it, the formula is as
follows:
=A2 + TIME(2, 0, 0)
Note. If you try adding more than 23 hours with the TIME function, the specified hours will be
divided by 24 and the remainder will be added to the start time value. For example, if you try to
add 25 hours to "6/2/2015 10:00 AM" (cell A4) using the formula =A4 + TIME(25, 0, 0), the result
will be "06/02/2015 11:00", i.e. A4 + 1 hour.
Universal formula to add any number of hours
The following formula has no limitations to the number of hours you want to add:
= Start time + (N hours / 24)
For example, to add 28 hours to the start time in cell A2, enter the following formula:
=A2 + (28/24)
To subtract hours from a given time, you use analogous formulas, and just replace "+" with the
minus sign:
For example, to subtract 3 hours from the time in cell A2, either of the following formulas will do:
=A2-(3/24)
=A2-TIME(3,0,0)
To subtract more than 23 hours, use the first one.
How to add / subtract minutes to time in Excel
To add minutes to a given time, employ the same techniques that we've just used for adding
hours.
To add or subtract under 60 minutes
Use the TIME function and supply the minutes you want to add or subtract in the second
argument:
=Start time + TIME(0, N minutes, 0)
And here are a couple of real-life formulas to calculate minutes in Excel:
To add 20 minutes to the time in A2: =A2 + TIME(0,20,0)
To subtract 30 minutes from the time in A2: =A2 - TIME(0,30,0)
To add or subtract any number of minutes
In your calculation, divide the number of minutes by 1440, which is the number of minutes in a
day, and add the quotient to the start time:
=Start time + (N minutes / 1440)
To subtract minutes from time, simply replace plus with the minus sign. For example:
Supposing you have a few project times in column B and you want to add them up. You write a
simple SUM formula like =SUM(B2:B4) and get the result in the default format, like hh:mm:ss.
In some cases the default time format works just fine, but sometimes you may want more, for
example to display the total time as minutes and seconds, or seconds only. The good news is
that no other calculations are required, all you have to do is apply custom time format to the cell
with the SUM formula.
Right click the cell and select Format Cells in the context menu, or press Ctrl + 1 to open
theFormat Cells dialog box. Select Custom from the Category list and type one of the following
time formats in the Type box:
Displays as
Explanation
[h]:mm
30:10
[h]:mm:ss
30:10:20
30 hours, 10 minutes, 20
seconds
d h:mm:ss
1 06:10:20
d "day" h:mm:ss
1 day 06:10:20
To see how these custom time formats may look like in your Excel worksheet, please have a
look at the screenshot below, where the same SUM formula is entered in cells A9 to A13:
=SUM($B$2:$B$4)
Note. The custom time formats discussed above work for positive values only. If the result of
your time calculations is a negative number, e.g. when you are subtracting a bigger time from a
smaller time, the result will be displayed as #####. To display negative times differently, please
see custom format for negative time values.
Also, please keep in mind that the time format applied to a cell changes only the display
presentation without changing the cell's value. For example, in the screenshot above, cell A13
looks like text, but in fact it's a usual time value, which is stored as a decimal in the internal
Excel system. What it means for you is that you are free to refer to that cell in other formulas
and calculations.
This is how you calculate time in Excel worksheets. I hope the time formulas discussed in this
article have proved useful for your tasks (you can download the Sample workbook with time
calculations to have a closer look). If not, I encourage you to check other parts to our
comprehensive tutorial to working with dates and times in Excel.
Excel time format & how to use NOW and TIME functions to insert time
In this tutorial, you will learn the specificities of Excel time format as well as how to add a
timestamp using shortcuts or insert an auto updatable time with the NOW function. You will also
learn how to apply special Excel time functions to get hours, minutes or seconds from a time
stamp.
Microsoft Excel has a number of helpful time features and knowing them a little in depth can
save you a lot of time. Using special functions, you can insert the current date and time
anywhere in a worksheet, convert time to a decimal number, sum different time units or
calculate the elapsed time.
To be able to leverage powerful Excel time functions, it helps to know how Microsoft Excel
stores times. So, before digging deeper into the formulas, let's invest a couple of minutes in
learning the basics of the Excel time format.
o
o
o
o
o
o
o
o
Now, you can write down that number and click Cancel to close the window. Or, you can click
theOK button and have the time replaced with a corresponding decimal number in the cell. In
fact, you can think of it as the fastest, easiest and formula-free way to convert time to
decimal in Excel. In the next part of our Excel Time tutorial, we'll take a closer look at special
time functions and calculations to convert time to hours, minutes or seconds.
How to apply or change the time format in Excel
Microsoft Excel is smart enough to recognize a time as you type and format the cell accordingly.
For example, if you type 20:30, or 8:30 PM, or even 8:30 p in a cell, Excel will interpret this as a
time and display either 20:30 or 8:30 PM, depending on your default time format.
If you want to format some numbers as times or apply a different time format to existing time
values, you can do this by using the Format Cells dialog, as demonstrated below.
1.
2.
In an Excel sheet, select the cell(s) where you want to apply or change the time format.
Open the Format Cells dialog either by pressing Ctrl + 1 or by clicking the Dialog Box
Launchericon next to Number in the Number group, on the Home tab.
3.
On the Number tab, select Time from the Category list, and choose the desired time
format from the Type list.
4.
Click OK to apply the selected time format and close the dialog box.
The custom time format you've created will be in the Type list the next time you need it.
Tip. The easiest way to create a custom time format in Excel is to use one of the existing
formats as a starting point. For this, click Time in the Category list, and select one of the
predefined formats under Type. After that switch to Custom and make the changes to the format
displayed in the Type box.
When creating a custom time format in Excel, you can use the following codes.
Code
Description
Displays as
0-23
hh
00-23
0-59
mm
00-59
0-59
ss
00-59
AM/PM
AM or PM
Tip. To create custom formatting for dates and time, use various combinations of time codes
and date codes.
The following table provides a few example of how your Excel time formats may look like:
Format
Displays as
h:mm:ss AM/PM
1:30:00 PM
h:mm
13:30
Displays as
Explanation
[h]:mm
41:30
[h]:mm:ss
41:30:10
40 hours, 30 minutes, 10
seconds
d h:mm:ss
1 17:30:10
d "day" h:mm:ss
1 day 17:30:10
1 day, 17 hours, 30
minutes and 10 seconds
Display an empty cell for negative times. Type a semicolon at the end of the time format,
for example [h]:mm;
Display an error message. Type a semicolon at the end of the time format, and then type
a message in quotation marks, e.g. [h]:mm;"Negative time"
Generally speaking, a semicolon acts as a delimiter to separate positive values' format from
negative values' formatting.
The default time format in Excel
When changing the time format in the Format Cells dialog, you may have noticed that one of the
formats begins with an asterisk (*). This is the default time format in your Excel.
To quickly apply the default Excel time format to the selected cell or a range of cells, click the
drop-down arrow in the Number group, on the Home tab, and select Time.
To change the default time format, go to the Control Panel and click Region and Language. If
in your Control panel opens in Category view, click Clock, Language, and Region > Region and
Language> Change the date, time, or number format.
Note. When creating a new Excel time format or modifying an existing one, please remember
that regardless of how you've chosen to display time in a cell, Excel always internally stores
times the same way - as decimal numbers.
How to insert time and a timestamp in Excel
There are a numbers of ways to insert time in Excel, which one to use depends on whether you
want a static timestamp or a dynamic value that updates automatically to reflect the current
time.
The NOW function retrieves time from your computer's system clock.
NOW is one of Excel's volatile functions that cause the cell with the formula to
recalculate every time the worksheet is re-opened or recalculated.
To force the Excel NOW function to update the returned value, press either Shift + F9 to
recalculate the active worksheet or F9 to recalculate all open workbooks.
To get the NOW function to automatically update at a specified time interval, add a VBA
macro to your workbook, a few examples are available here.
Insert current time as a dynamic value
If you'd rather insert only the current time in a cell without a date, you have the following
choices:
1.
Use =NOW() formula, and then apply the time format to a cell(s).
Please remember, this will only change the display format, the actual value stored in a cell
will still be a decimal number consisting of an integer representing the date and a fractional
part representing the time.
2.
The INT function is used to round the decimal number returned by NOW() down to the
nearest integer. And then, you subtract the integer part representing today's date to output
only the fractional part that represents the current time.
Since the formula returns a decimal, you will need to apply the time format to the cell to
make the value display as time.
The following screenshot demonstrates both formulas in action. Pay attention that although the
formatted time values look the same (column C), the actual values stored in cells (column D)
are different - D4 contains only the fractional part:
If hour is greater than 23, it is divided by 24 and the remainder is taken as the hour
value.
For example, TIME(30, 0, 0) equates to TIME(6,0,0), which is 0.25 or 6:00 AM.
If minute is greater than 59, it is converted to hours and minutes. And if second is
greater than 59, it is converted to hours, minutes, and seconds.
For example, TIME(0, 930, 0) is converted to TIME(15, 30, 0), which is 0.645833333 or 15:30.
The Excel TIME function is useful when it comes to merging individual values into a single time
value, for example values in other cells or returned by other Excel functions.
Now that you've got down to brass tacks of the Excel time format and time functions, it will be
much easier for you to manipulate dates and times in your worksheets. In the next part of our
Excel Time tutorial, we are going to discuss different ways of converting time to numbers. I
thank you for reading and hope to see you on our blog next week!
At first sight, the Excel DATE function looks very simple, however, it does have a number of
specificities pointed out in the Excel DATE tutorial.
Below you will find a few more examples where the Excel DATE function is part of bigger
formulas:
=WORKDAY(TODAY(), 30)
Note. The date returned by the TODAY function in Excel updates automatically when your
worksheet is recalculated to reflect the current date.
If your goal is to get a static timestamp in your Excel sheet, then use one of the following
shortcuts:
To make the NOW() function automatically update every second or so, a VBA macro is needed
(a few examples are available here).
Excel DATEVALUE function
DATEVALUE(date_text) converts a date in the text format to a serial number that Microsoft
Excel recognizes as a date.
The DATEVALUE function understands plenty of date formats as well as references to cells that
contain "text dates". DATEVALUE comes in really handy to calculate, filter or sort dates stored
as text and convert such "text dates" to the Date format.
A few simple DATEVALUE formula examples follow below:
=DATEVALUE("20-may-2015")
=DATEVALUE("5/20/2015")
=DATEVALUE("may 20, 2015")
And the following examples demonstrate how the DATEVALUE function can help with solving
real-life tasks:
With the TEXT(value, format_text) function, you can change the dates to text strings in a variety
of formats, as demonstrated in the following screenshot.
Note. Though the values returned by the TEXT function may look like usual Excel dates, they
are text values in nature and therefore cannot be used in other formulas and calculations.
Here are a few more TEXT formula examples that you may find helpful:
You can find more DAY formula examples by clicking the following links:
A positive value in the months argument adds the corresponding number of months to
the start date, for example:
=EOMONTH(A2, 3) - returns the last day of the month, 3 months after the date in cell A2.
A zero in the months argument forces the EOMONTH function to return the last day of
the start date's month:
=EOMONTH(DATE(2015,4,15), 0) - returns the last day in April, 2015.
To get the last day of the current month, enter the TODAY function in
the start_dateargument and 0 in months:
=EOMONTH(TODAY(), 0)
You can find a few more EOMONTH formula examples in the following articles:
=WEEKDAY(TODAY()) - returns a number corresponding to today's day of the week; the week
begins on Sunday.
The WEEKDAY function can help you determine which dates in your Excel sheet are working
days and which ones are weekend days, and also sort, filter or highlight workdays and
weekends:
These are just the basic applications of the DATEDIF function and it is capable of much more,
as demonstrated in the following examples:
This very specific function can be used to solve practical tasks such as calculating age from
date of birth.
Excel WORKDAY function
WORKDAY(start_date, days, [holidays]) function returns a date N workdays before or after
the start date. It automatically excludes weekend days from calculations as well as any holidays
that you specify.
This function is very helpful for calculating milestones and other important events based on the
standard working calendar.
For example, the following formula adds 45 weekdays to the start date in cell A2, ignoring
holidays in cells B2:B8:
=WORKDAY(A2, 45, B2:B85)
For the detailed explanation of WORKDAY's syntax and more formula examples, please check
outWORKDAY function - add or subtract workdays in Excel.
Excel WORKDAY.INTL function
WORKDAY.INTL(start_date, days, [weekend], [holidays]) is a more powerful variation of
the WORKDAY function introduced in Excel 2010 and also available Excel 2013 and 2016.
WORKDAY.INTL allows calculating a date N number of workdays in the future or in the past with
custom weekend parameters.
For example, to get a date 20 workdays after the start date in cell A2, with Monday and Sunday
counted as weekend days, you can use either of the following formulas:
=WORKDAY.INTL(A2, 20, 2, 7)
or
=WORKDAY.INTL(A2, 20, "1000001")
Of course, it might be difficult to grasp the essence from this short explanation, but more
formula examples illustrated with screenshots will make things really easy: WORKDAY.INTL calculating workdays with custom weekends.
Excel NETWORKDAYS function
NETWORKDAYS(start_date, end_date, [holidays]) function returns the number of weekdays
between two dates that you specify. It automatically excludes weekend days and, optionally, the
holidays.
For example, the following formula calculates the number of whole workdays between the start
date in A2 and end date in B2, ignoring Saturdays and Sundays and excluding holidays in cells
C2:C5:
=NETWORKDAYS(A2, B2, C2:C5)
You can find a comprehensive explanation of the NETWORKDAYS function's arguments
illustrated with formula examples and screenshots in the following tutorial: NETWORKDAYS
function - calculating workdays between two dates.
Excel NETWORKDAYS.INTL function
NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays]) is a more powerful
modification of the NETWORKDAYS function available in the modern versions of Excel 2010,
Excel 2013 and Excel 2016. It also returns the number of weekdays between two dates, but lets
you specify which days should be counted as weekends.
Here is a basic NETWORKDAYS formula:
=NETWORKDAYS(A2, B2, 2, C2:C5)
The formula calculates the number of workdays between the date in A2 (start_date) and the
date in B2 (end_date), excluding the weekend days Sunday and Monday (number 2 in the
weekend parameter), and ignoring holidays in cells C2:C5.
For full details about the NETWORKDAYS.INTL function, please see NETWORKDAYS function
- counting workdays with custom weekends.
Hopefully, this 10K foot view on the Excel date functions has helped you gain the general
understanding of how date formulas work in Excel. If you want to learn more, I encourage you to
check out the formula examples referenced on this page. I thank you for reading and hope to
see you again on our blog next week!
o
o
o
o
o
If year is between 1900 and 9999 inclusive, exactly that value is used for the year. For
example, =DATE(2015, 12, 31) returns December 31, 2015.
If the year argument is between 0 and 1899 inclusive, Excel calculates the year by
adding the specified number to 1900. For example, =DATE(100, 12, 31) returns December 31,
2000 (1900 + 100).
If year is less than 0 or greater than 9999, a DATE formula will return the #NUM! error.
Tip. To avoid confusion, always supply four digit years. For example, if you input "01" or "1" in
the year argument, your DATE formula will return the year of 1901.
Month - an integer representing the month of the year, from 1 (January) to 12 (December).
If month is greater than 12, Excel adds that number to the first month in the specified
year. For example, =DATE(2015, 15, 5) returns the serial number representing March 1, 2016
(January 5, 2015 plus 15 months).
If month is less than 1 (zero or negative value), Excel subtracts the magnitude of that
number of months, plus 1, from the first month in the specified year. For example, =DATE(2015,
-5, 1) returns the serial number representing July 1, 2014 (January 1, 2015 minus 6 months).
Day - an integer corresponding to the day of the month, from 1 to 31.
As well as month, the day argument can be supplied as a positive and negative number, and
Excel calculates its value based on the same principles as described above.
Tip. At first sight, supplying negative values in the month or day argument of the Excel DATE
function may seem absurd, but in practice it may turn out quite useful, for example in the
complex formula that converts a week number to a date.
The DATE function is available in all versions of Excel 2013, Excel 2010, Excel 2007, 2003, XP,
2000 as well as in Excel 2016.
Excel DATE formula examples
Blow you will find a few examples of using DATE formulas in Excel beginning with the simplest
ones.
Example 1. A simple DATE formula to return a serial number for a date
This is the most obvious use of the DATE function in Excel:
=DATE(2015, 5, 20) - returns a serial number corresponding to 20-May-2015.
Instead of specifying the values representing the year, month and day directly in a date formula,
you can get some or all arguments as results of other Excel date functions:
=DATE(YEAR(TODAY()), 1, 1) - returns the serial number for the first day of the current year.
=DATE(YEAR(TODAY()), MONTH(TODAY(), 1) - returns the serial number for the first day of
the current month in the current year.
Example 2. Excel DATE formula to return a date based on values in other cells
The DATE function is very helpful for calculating dates where the year, month, and day values
are stored in other cells. For example:
=DATE(A2, A3, A4) - returns the serial number for the date, taking the values in cells A2, A3
and A4 as the year, month and day arguments, respectively.
If you are adding or subtracting two dates that are stored in some cells, then the formula is as
simple as =A1+B1 or A1-B1, respectively.
For more information, please see:
How to convert week number to date - the example demonstrates how you can get a
date in Excel based on the week number, and also how to get a month corresponding to the
week number.
Find the first day of month - how to get the 1st day of the month by the month number,
from a given date and based on today's date.
Calculate the number of days in a month - how to get the number of days based on the
month number or on a date.
Determine leap and non-leap years - two Date formulas to pin down leap years in Excel.
Convert a month number to month name - how to change a month number to the month
name by using a combination of Excel TEXT and DATE functions.
Get the day of the year in Excel - this example explains a DATE/YEAR formula to get a
day's number.
Using Excel DATE formulas in conditional formatting
In case you want not only to calculate but also highlight dates in your Excel worksheets, then
create conditional formatting rules based on DATE formulas.
Supposing you have a list of dates in column A and you want to shade dates that occurred
earlier than 1-May-2015 in orange and those that occur after 31-May-2015 in green.
For the detailed steps and more formula examples, please see How to conditionally format
dates in Excel.
Though DATE is the main function to work with dates in Excel, a lot of additional functions are
available that tackle more specific tasks. Next week, we will provide an overview of all Excel
date functions illustrated with formula examples and complemented with links to other
resources. I thank you for reading and please stay tuned!
Excel DATEDIF - calculate difference between two dates in days, weeks, months or
years
In this tutorial, you will find a simple explanation of the Excel DATEDIF function and a few
formula examples that demonstrate how to compare dates and calculate the difference in days,
weeks, months or years.
Over the past few weeks, we investigated nearly every aspect of working with dates and times
in Excel. If you have been following our blog series, you already know how to insert and format
dates in your worksheets, how to calculate days, weeks, months and years as well as add and
subtract dates.
In this tutorial, we will focus on calculating date difference in Excel and you will learn different
ways to count the number of days, weeks, months and years between two dates.
Cell references. For example, the following formula counts the number of days between
the dates in cells A1 and B1:
=DATEDIF(A1, B1, "d")
Test strings. Excel understands dates in many formats, for example "20-May-2015",
"5/20/2015", "2015/5/20", etc. The following formula calculates the number of months between
the specified dates:
=DATEDIF("5/10/2015", "7/20/2015", "m")
Serial numbers. Since Microsoft Excel stores each date as a serial number beginning
with January 1, 1900, you can put numbers corresponding to the dates directly in the formula.
Although fully supported, this method is not reliable because date numbering varies on different
computer systems. In the 1900 date system, the following formula is another way to calculate
months between two dates from the previous example (10-May-2015 and 20-Jul-2015):
=DATEDIF(42134, 42205, "m")
Results of other functions. For instance, the following formula counts how many days
there are between today's date and 20 May, 2015.
=DATEDIF(TODAY(), "5/20/2015", "d")
Note. In your formulas, the end date must always be greater than the start date, otherwise the
Excel DATEDIF function returns the #NUM! error.
Unit - the time unit to use when calculating the difference between two dates. By supplying
different units, you can get the DATEDIF function to return the date difference in days, months
or years. Overall, 6 units are available, which are described in the following table.
Unit
Meaning
Explanation
Years
Months
Days
MD
YD
YM
Hopefully, the above information has been helpful to understand the basics. And now, let's see
how you can use the Excel DATEDIF function to compare dates in your worksheets and return
the difference.
Excel DATEDIF formulas to calculate date difference in days
If you observed DATEDIF's arguments carefully, you've noticed that there exist 3 different units
for counting days between the dates. Which one to use depends on exactly what your needs
are.
Example 1. Count the number of days between two dates
Supposing you have the start date in cell A2 and the end date in cell B2 and you want Excel to
return the date difference in days. A simple DATEDIF formula works just fine:
=DATEDIF(A2, B2, "d")
Provided that a value in the start_date argument is less than in end_date. In case the start date
is greater than the end date, the Excel DATEDIF function returns the #NUM error, as in row 5:
If you are looking for a formula that can return the date difference in days as either a positive or
negative number, simply subtract one date directly from the other:
=B2-A2
Please see How to subtract dates in Excel for full details and more formula examples.
Example 2. Count days in Excel ignoring years
Supposing you have two lists of dates that belong to different years and you wish to calculate
the number of days between the dates as if they were of the same year. To do this, use a
DATEDIF formula with "YD" unit:
If you want the Excel DATEDIF function to ignore not only years but also moths, then use the
"md" unit. In this case, your formula will calculate days between two dates as if they were of the
same month and the same year:
=DATEDIF(A2, B2, "md")
The screenshot below demonstrates the results, and comparing it with the screenshot above
can help understand the difference better.
Tip. To get the number of working days between two dates, use
the NETWORKDAYS orNETWORKDAYS.INTL function.
Calculating date difference in weeks
As you probably noticed, the Excel DATEDIF function does not have a special unit to calculate
date difference in weeks. However, there is an easy workaround.
To find out how many weeks there are between two dates, you can use the DATEDIF function
with "D" unit to return the difference in days, and then divide the result by 7.
To get the number of full weeks between the dates, wrap your DATEDIF formula in the
ROUNDDOWN function, which always rounds the number towards zero:
=ROUNDDOWN((DATEDIF(A2, B2, "d") / 7), 0)
Where A2 is the start date and B2 is the end date of the period you are calculating.
As you see, this formula also returns an error in row 6 where end date is less than the start
date. If your data set may contain such dates, you will find the solution in the next examples.
Example 3. Calculating months between two dates (MONTH function)
An alternative way to calculate the number of months between two dates in Excel is using the
MONTH function, or more precisely a combination of MONTH and YEAR functions:
=(YEAR(B2) - YEAR(A2))*12 + MONTH(B2) - MONTH(A2)
Of course, this formula is not so transparent as DATEDIF and it does take time to wrap your
head around the logic. But unlike the DATEDIF function, it can compare any two dates and
Notice that the YEAR/MONTH formula has no problem with calculating months in row 6 where
the start date is more recent than the end date, the scenario in which an analogues DATEDIF
formulafails.
Note. The results returned by DATEDIF and YEAR/MONTH formulas are not always identical
because they operate based on different principles. The Excel DATEDIF function returns the
number of complete calendar months between the dates, while the YEAR/MONTH formula
operates on months' numbers.
For example, in row 7 in the screenshot above, the DATEDIF formula returns 0 because a
complete calendar month between the dates has not elapsed yet, while YEAR/MONTH returns
1 because the dates belong to different months.
Example 4. Counting months between 2 dates ignoring years (MONTH function)
In case all of your dates are of the same year, or you want to calculate months between the
dates ignoring years, you can the MONTH function to retrieve the month from each date, and
then subtract one month from the other:
=MONTH(B2) - MONTH(A2)
This formula works similarly to Excel DATEDIF with "YM" unit as demonstrated in the following
screenshot:
Row 4: the end date is less than the start date and therefore DATEDIF returns an error
while MONTH-MONTH yields a negative value.
Row 6: the dates are of different months, but the actual date difference is just one day.
DATEDIF returns 0 because it calculates whole months between 2 dates. MONTH-MONTH
returns 1 because it subtracts the months' numbers from each other ignoring days and years.
How to calculate years between two dates in Excel
If you followed the previous examples where we calculated months and days between two
dates, then you can easily derive a formula to calculate years in Excel. The following examples
can help you check if you got the formula right :)
Example 1. Calculating complete years between two dates (DATEDIF function)
To find out the number of complete calendar years between two dates, use the old good
DATEDIF with the "Y" unit:
Notice that the DATEDIF formula returns 0 in row 6, although the dates are of different years.
This is because the number of full calendar years between the start and end dates equals to
zero. And I believe you are not surprised to see the #NUM! error in row 7 where the start date is
more recent than the end date.
Example 2. Calculating years between two dates (YEAR function)
An alternative way to calculate years in Excel is using the YEAR function. Similarly to
the MONTH formula, you extract the year from each date, and then subtract the years from
each other:
=YEAR(B2) - YEAR(A2)
In the following screenshot, you can compare the results returned by the DATEDIF and YEAR
functions:
The DATEDIF function calculates complete calendar years, while the YEAR formula
simply subtracts one year from the other. Row 6 illustrates the difference.
The DATEDIF formula returns an error if the start date is greater than the end date, while
the YEAR function returns a negative value, as in row 7.
How to calculate date difference is days, months and years
To count the number of complete years, months and days between two dates in a single
formula, you simply concatenate three DATEDIF functions:
=DATEDIF(A2, B2, "y") &" years, "&DATEDIF(A2, B2, "ym") &" months, " &DATEDIF(A2,
B2, "md") &" days"
If you'd rather not display zero values, you can wrap each DATEDIF in the IF function as
follows:
=IF(DATEDIF(A2,B2,"y")=0, "", DATEDIF(A2,B2,"y") & " years ") &
IF(DATEDIF(A2,B2,"ym")=0,"", DATEDIF(A2,B2,"ym") & " months ") & IF(DATEDIF(A2, B2,
"md")=0, "", DATEDIF(A2, B2, "md") & " days"
The formula displays only non-zero elements as demonstrated in the following screenshot:
The above formula calculates the number of complete years. If you'd rather get the exact age,
including years, months and days, then concatenate three DATEDIF functions like we did in the
previous example:
=DATEDIF(B2,TODAY(),"y") & " Years, " & DATEDIF(B2,TODAY(),"ym") & " Months, " &
DATEDIF(B2,TODAY(),"md") & " Days"
And you will get the following result:
To learn other methods of converting a birthdate to age, check out How to calculate age from
date of birth.
This is how you compute the difference between two dates in a variety of time intervals.
Hopefully, the DATEDIF function and other formulas you've learned today will prove useful in
your worksheets. Anyway, I thank you for reading and invite to check out other parts of our
tutorial to working with days and time in Excel.
Holidays - an optional list of dates that should not to be counted as working days. This
can be either a range of cells containing the dates you want to exclude from calculations, or an
array constant of the serial numbers representing the dates.
Now that you know the basics, let's see how you can use the WORKDAY function in your Excel
worksheets.
How to use WORKDAY in Excel - formula examples
Supposing you have a start date in cell A2 and a list of holidays in cells B2:B5 and you want to
find out the dates 30 workdays in the future and past. You can do this using the following
formulas:
o
o
And naturally, you can enter the number of workdays to add to / subtract from the start date in
some cell, and then refer to that cell in your formula. For example:
=WORKDAY(A2, C2)
Where A2 is the start date and C2 is the number of non-weekend days behind (negative
numbers) or ahead of (positive numbers) the start date, no holidays to exclude.
Weekend days
1 or omitted
Saturday, Sunday
Sunday, Monday
Monday, Tuesday
Tuesday, Wednesday
Wednesday, Thursday
Thursday, Friday
Friday, Saturday
11
Sunday only
12
Monday only
13
Tuesday only
14
Wednesday only
15
Thursday only
16
Friday only
17
Saturday only
Weekend string - a series of seven 0's and 1's that represent seven days of the week,
beginning with Monday. 1 represents a non-working day and 0 represents a workday. For
example:
To add 30 workdays to the start date, Friday and Saturday counted as weekends and
holidays in A5:A8 excluded:
=WORKDAY.INTL(A2, 30, 7, A5:A8)
or
=WORKDAY.INTL(A2, 30, "0000110", A5:A8)
To subtract 30 workdays from the start date, Sunday and Monday counted as weekends
and holidays in A5:A8 excluded:
To add 10 workdays to the current date, Sunday being the only weekend day, no
holidays:
=WORKDAY.INTL(TODAY(), 10, 11)
or
=WORKDAY.INTL(A2, 10, "0000001")
In your Excel sheet, the formulas may look similar to this:
Note. Both Excel WORKDAY and WORKDAY.INTL functions return serial numbers representing
the dates. To get those numbers displayed as dates, select the cells with the numbers and
press Ctrl+1 to open the Format Cells dialog. On the Number tab, select Date in
the Categorylist, and choose the date format you want. For the detailed steps, please see How
to change date format in Excel.
Excel WORKDAY and WORKDAY.INTL errors
If your Excel WORKDAY or WORKDAY.INTL formula returns an error, the reason is likely to be
one of the following:
#NUM! error occurs if either:
Holidays - an optional list of holidays that are not to be counted as work days.
How to use NETWORKDAYS in Excel - formula examples
Let's say you have a list of holidays in cells A2:A5, start dates in column B, end dates in column
C, and you want to know how many workdays are between these dates. The appropriate
NETWORKDAYS formula is easy to figure out:
=NETWORKDAYS(B2, C2, $A$2:$A$5)
Notice that the Excel NETWORKDAYS function returns a positive value when the start date is
less than the end date, and a negative value if the end date is more recent than the start date
(as in row 5):
Let's try to figure out why that happens. The problem is not with the WORKDAY function, as
someone may conclude. The function is right, but... what does it actually do? It returns a date 15
workdays from now, excluding weekend days (Saturday and Sunday) and holidays in cells
A2:A3.
Okay, and what does the rule based on this formula do? It highlights ALL the dates that are
equal to or greater than today and less than the date returned by the WORKDAY function. You
see? All the dates! If you don't want to color the weekends and holidays, then you need to
explicitly tell Excel not to. So, we are adding two more conditions to our formula:
As you see, the WORKDAY and WORKDAY.INTL functions make calculating workdays in Excel
quick and easy. Of course, your real-life formulas are likely to be more sophisticated, but
knowing the basics helps immensely, because you can remember only a small set of essential
things and derive the rest. I thank you for reading and hope to see on our blog next week!
How to add and subtract dates, days, weeks, months and years in Excel
In this tutorial, you will find a variety of useful formulas to add and subtract dates in Excel, such
assubtracting two dates, adding days, weeks, months and years to a date, and more.
If you have been following our tutorial to working with dates in Excel, you already know an array
of formulas to calculate different time units such as days, weeks, months and years.
When analyzing the date information in your worksheets, you are likely to perform some
arithmetic operations with those dates too. This tutorial explains a few formulas for adding and
subtracting dates in Excel that you may find useful.
Wrapping up, when it comes to subtracting dates in Excel and you want to find out how many
days are between two dates, it makes sense to go with the easiest and most obvious option simply subtract one date directly from another.
If you are looking to count the number of months or years between two dates, then the
DATEDIF function is the only possible solution and you will find a few formula examples in the
next article that will cover this function in full details.
Now that you know how to subtract two dates, let's see how you can add or subtract days,
months, or years to a given date. There are a number of Excel functions suitable for this
purpose, and which one you use depends on which unit you want to add or subtract.
How to subtract or add days to date in Excel
If you have a date in some cell or a list of dates in a column, you can add or subtract a certain
number of days to those dates using a corresponding arithmetic operation.
Example 1. Adding days to a date in Excel
The general formula to add a specified number of days to a date in as follows:
=Date + N days
The date can be entered in several ways:
Note. The result of the above formulas is a serial number representing the date. To get it
displayed as a date, select the cell(s) and press Ctrl+1 to open the Format Cells dialog. On
theNumber tab, select Date in the Category list, and then choose the date format you want. For
the detailed steps, please see How to change date format in Excel.
=A2 - 10
=DATE(2015, 5, 6) - 10
=TODAY() - 10
Now, let's see what the function is actually doing. The logic behind the formula is obvious and
straightforward. The DATE(year, month, day) function takes the following arguments:
Naturally, nothing prevents you from typing the minus sign directly in the formula to subtract
months from a date:
Start_date - the start date from which to count the number of months.
Months - the number of months to add (a positive value) or subtract (a negative value).
The following formula used on our column of dates yields exactly the same results as the DATE
function in the previous example:
When using the EDATE function, you can also specify the start date and the number of month to
add / subtract directly in the formula. Dates should be entered by using the DATE function or as
results of other formulas. For example:
If the original cells contain both date and time, the above formula works perfectly too:
This is how you add and subtract dates in Excel. I am hopeful you have learned a couple of
useful functions today. Anyway, I thank you for reading and hope to see you on our blog next
week.
How to convert date to year in Excel & calculate age from date of birth
This tutorial explains the syntax and uses of the Excel YEAR function and provides formula
examples to extract year from date, convert date to month and year, calculate age from the date
of birth anddetermine leap years.
In a few recent posts, we have explored different ways to calculate dates and times in Excel and
learned a variety of useful functions such as WEEKDAY, DAY, MONTH and WEEKNUM. Today,
we are going to focus on a bigger time unit and talk about calculating years in your Excel
worksheets.
In this tutorial, you will learn:
o
o
o
Using the DATE For example, the following formula returns the year for 28 April, 2015:
=YEAR(DATE(2015,4,28))
As a serial number representing the date (for more information on how dates are stored
in Excel, please see Excel date format). The 28 day of April, 2015 is stored as 42122, so you
can enter this number directly in the formula:
=YEAR(42122)
Although you can enter a date as a serial numbers, this method is not recommended because
date numbering may vary across different systems.
Simple YEAR formulas can even understand dates entered as text, like =YEAR("28-Apr-2015").
However, Microsoft does not guarantee correct results when a date is supplied as a text value.
The following screenshot demonstrates all of the above YEAR formulas in action, all returning
2015 as you might expect :)
Please remember that this method does not change the original date, it only changes the way
the date is displayed in your worksheet. If you refer to such cells in your formulas, Microsoft
Excel will perform date calculations rather than year calculations.
You can find more details about changing the date format in this tutorial: How to change date
format in Excel.
How to calculate age from date of birth in Excel
Usually, we have no problem with calculating someone's age if we know the person's birthdate.
But how do you approach this task in Excel? There are a few functions that can help you quickly
convert dates of birth to age, as demonstrated in the formula examples that follow.
Example 1. Convert date of birth to age with TODAY function
How do you normally figure out someone's age? Yep, by subtracting the birth date from the
current date. And the Excel age calculation formula is no different.
Supposing you have dates of birth in column B, you can convert them to a person's age using
this simple formula:
=(TODAY()-B2)/365
The first part of the formula (TODAY()-B2) calculates the difference is days, and you get years
by dividing that number by 365.
However, there is a tiny problem here. The formula returns a number with a few decimal points
as demonstrated in the screenshot below.
If you'd rather have complete years, then use the INT function that rounds the number down to
the nearest integer:
=INT((TODAY()-B2)/365)
Note. This age calculation formula produces pretty accurate results but it isn't flawless. Dividing
by the average number of days in a year works most of the time, but sometimes it gets the age
wrong. For example, if someone was born on February 29 and today is February 28, the
formula will make the person one day older (girls would certainly mind that :)
As an alternative, you can divide by 365.25 instead of 365 since every fourth year has 366 days.
However, this formula is not perfect either. For example, if you are calculating the age of a child
who hasn't yet lived through a leap year, dividing by 365.25 produces a wrong result.
Overall, subtracting the birth date from the current date works great in normal life, but is not the
ideal approach in Excel. So, I invite you to discover special Excel functions that calculate the
age impeccably regardless of the year.
1.
2.
3.
Oops, not exactly what we were looking for, uh? To make the result more sensible, let's
separate the returned numbers with commas and define what each number means:
=DATEDIF(B2,TODAY(),"Y") & " Years, " & DATEDIF(B2,TODAY(),"YM") & " Months, " &
DATEDIF(B2,TODAY(),"MD") & " Days"
The results look much better now:
This formula may come in very handy, say, for a doctor to display the exact age of patients, or
for a personnel officer to know the exact age of all employees.
Calculating leap years in Excel
As you know, nearly every 4th year has an extra day on February 29 and is called a leap year. In
Microsoft Excel sheets, you can determine whether a certain date belongs to a leap year or a
common year in a variety of ways. I'm going to demonstrate just a couple of formulas, which in
my opinion are easiest to understand.
Alternatively, you can use the EOMONTH function to return the last day in February, and
compare that number with 29:
=DAY(EOMONTH(DATE(YEAR(A2),2,1),0))=29
To make the formula more user-friendly, employ the IF function and have it return, say, "Leap
year" and "Common year" instead of TRUE and FALSE:
=IF(DAY(DATE(YEAR(A2),3,1)-1)=29, "Leap year", "Common year")
=IF(DAY(EOMONTH(DATE(YEAR(A2),2,1),0))=29, "Leap year", "Common year")
As already mentioned, these are not the only possible ways to calculate leap years in Excel. If
you are curious to know other solutions, you can check the method suggested by Microsoft. (As
usual, Microsoft guys are not looking for easy ways, are they?) And you can find 14 other
formulas onthis blog.
Hopefully, this article has helped you figure out year calculations in Excel. I thank you for
reading and look forward to seeing you next week.
WEEKNUM(serial_number, [return_type])
Serial_number - any date within the week whose number you are trying to find. This
can be a reference to a cell containing the date, a date entered by using the DATE function or
returned by some other formula.
Return_type (optional) - a number that determines on which day the week begins. If
omitted, the default type 1 is used (the week beginning on Sunday).
Here is a complete list of the return_type values supported in WEEKNUM formulas.
Return_type
Week begins on
1 or 17 or omitted
Sunday
2 or 11
Monday
12
Tuesday
13
Wednesday
14
Thursday
15
Friday
16
Saturday
21
In the WEEKNUM function, two different week numbering systems are used:
System 1. The week containing January 1 is considered the 1st week of the year and is
numbered week 1. In this system, the week traditionally starts on Sunday.
System 2. This is the ISO week date system that is part of the ISO 8601 date and time
standard. In this system, the week starts on Monday and the week containing the first Thursday
of the year is considered week 1. It is commonly known as the European week numbering
system and it is used mainly in government and business for fiscal years and timekeeping.
All of the return types listed above apply to System 1, except for return type 21 that is used in
System 2.
Note. In Excel 2007 and earlier versions, only options 1 and 2 are available. Return types 11
through 21 are supported in Excel 2010 and Excel 2013 only.
Excel WEEKNUM formulas to convert date to week number
The following screenshot demonstrates how you can get week numbers from dates with the
simplest =WEEKNUM(A2) formula:
In the above formula, the return_type argument is omitted, which means that the default type 1
is used - the week beginning on Sunday.
If you'd rather begin with some other day of the week, say Monday, then use 2 in the second
argument:
=WEEKNUM(A2, 2)
Instead of referring to a cell, you can specify the date directly in the formula by using the
DATE(year, month, day) function, for example:
=WEEKNUM(DATE(2015,4,15), 2)
The above formula returns 16, which is the number of the week containing April 15, 2015, with a
week beginning on Monday.
In real-life scenarios, the Excel WEEKNUM function is rarely used on its own. Most often you
would use it in combination with other functions to perform various calculations based on the
week number, as demonstrated in further examples.
How to convert week number to date in Excel
As you have just seen, it's no big deal to turn a date into a week number using the Excel
WEEKNUM function. But what if you are looking for the opposite, i.e. converting a week number
to a date? Alas, there is no Excel function that could do this straight away. So, we will have to
construct our own formulas.
Supposing you have a year in cell A2 and a week number in B2, and now you want to calculate
the Start and End dates in this week.
Note. This formula example is based on ISO week numbers, with a week starting on Monday.
The formula to return the Start date of the week is as follows:
=DATE(A2, 1, -2) - WEEKDAY(DATE(A2, 1, 3)) + B2 * 7
Where A2 is the year and B2 is the week number.
Please note that the formula returns the date as a serial number, and to have it displayed as a
date, you need to format the cell accordingly. You can find the detailed instructions in Changing
date format in Excel. And here is the result returned by the formula:
Of course, the formula to convert a week number to a date is not trivial, and it may take a while
to get your head round the logic. Anyway, I will do my best to provide meaningful explanation for
those who are curious to get down to the bottom.
As you see, our formula consists of 2 parts:
DATE(A2, 1, -2) - WEEKDAY(DATE(A2, 1, 3)) - calculates the date of the last Monday in
the previous year.
B2 * 7 - adds the number of weeks multiplied by 7 (the number of days in a week) to get
the Monday (start date) of the week in question.
In the ISO week numbering system, week 1 is the week containing the first Thursday of the
year. Consequently, the first Monday is always between December 29 and January 4. So, to find
that date, we have to find the Monday immediately before January 5.
In Microsoft Excel, you can extract a day of week from a date by using the WEEKDAY function.
And you can use the following generic formula to get Monday immediately before any given
date:
=date - WEEKDAY(date - 2)
If our ultimate goal were to find Monday immediately before the 5th of January of the year in A2,
we could use the following DATE(year, month, day) functions:
=DATE(A2,1,5) - WEEKDAY(DATE(A2,1,3))
But what we actually need is not the first Monday of this year, but rather the last Monday of the
previous year. So, you have to subtract 7 days from January 5 and hence you get -2 in the first
DATE function:
=DATE(A2,1,-2) - WEEKDAY(DATE(A2,1,3))
Compared to the tricky formula you have just learned, calculating the End date of the week is a
piece of cake :) To get Sunday of the week in question, you simply add 6 days to the Start date,
i.e. =D2+6
D and E, respectively:
Obviously, you can wrap the Start date formula in the Excel MONTH function to get a month
corresponding to the week number.
=MONTH(DATE(A2, 1, -2) - WEEKDAY(DATE(A2, 1, 3)) + B2 * 7)
An alternative way to convert a week number to a date in Excel is using the MAX and MIN
functions, as follows:
Start date:
=MAX(DATE(A2,1,1), DATE(A2,1,1) - WEEKDAY(DATE(A2,1,1),2) + (B2-1)*7 + 1)
End date:
in cell C2.
And then, make a list of week numbers in some other column (say, in column E) and calculate
the sales for each week using the following SUMIF formula:
=SUMIF($C$2:$C$15, $E2, $B$2:$B$15)
Where E2 is the week number.
In this example, we are working with a list of March sales, so we have week numbers 10 to 14,
as demonstrated in the following screenshot:
In a similar manner, you can calculate the sales average for a given week:
=AVERAGEIF($C$2:$C$15, $E2, $B$2:$B$15)
If the helper column with the WEEKNUM formula does not fit well into your data layout, I regret
to tell you that there is no simple way to get rid of it because Excel WEEKNUM is one of those
functions that doesn't accept range arguments. Therefore, it cannot be used within
SUMPRODUCT or any other array formula like the MONTH function in a similar scenario.
How to highlight cells based on the week number
Let's say you have a long list of dates in some column and you want to highlight only those that
relate to a given week. All you need is a conditional formatting rule with a WEEKNUM formula
similar to this:
=WEEKNUM($A2)=10
As demonstrated in the screenshot below, the rule highlights sales that were made within week
10, which is the first week in March 2015. Since the rule applies to A2:B15, it highlights values in
both columns. You can learn more about creating conditional formatting rules in this
This is how you can calculate week numbers in Excel, convert week number to date and extract
week number from date. Hopefully, the WEEKNUM formulas you have learned today will prove
useful in your worksheets. In the next tutorial, we will talk about calculating age and years in
Excel. I thank you for reading and hope to see you next week!
If you don't actually want to convert date to month in your Excel worksheet, you are just wish
todisplay a month name only instead of the full date, then you don't want any formulas.
Select a cell(s) with dates, press Ctrl+1 to opent the Format Cells dialog. On the Number tab,
selectCustom and type either "mmm" or "mmmm" in the Type box to display abbreviated or full
month names, respectively. In this case, your entries will remain fully functional Excel dates that
you can use in calculations and other formulas. For more details about changing the date
format, please see Creating a custom date format in Excel.
=TEXT(A2*28, "mmmm")
=TEXT(DATE(2015, A2, 1), "mmmm")
In all of the above formulas, A2 is a cell with a month number. And the only real difference
between the formulas is the month codes:
EOMONTH(start_date, months)
Start_date - the starting date or a reference to a cell with the start date.
Months - the number of months before or after the start date. Use a positive value for
future dates and negative value for past dates.
Here are a few EOMONTH formula examples:
=EOMONTH(A2, 1) - returns the last day of the month, one month after the date in cell A2.
=EOMONTH(A2, -1) - returns the last day of the month, one month before the date in cell A2.
Instead of a cell reference, you can hardcode a date in your EOMONTH formula. For example,
both of the below formulas return the last day in April.
=EOMONTH("15-Apr-2015", 0)
=EOMONTH(DATE(2015,4,15), 0)
To return the last day of the current month, you use the TODAY() function in the first
argument of your EOMONTH formula so that today's date is taken as the start date. And, you
put 0 in the months argument because you don't want to change the month either way.
=EOMONTH(TODAY(), 0)
Note. Since the Excel EOMONTH function returns the serial number representing the date, you
have to apply the date format to a cell(s) with your formulas. Please see How to change date
format in Excel for the detailed steps.
And here are the results returned by the Excel EOMONTH formulas discussed above:
If you want to calculate how many days are left till the end of the current month, you simply
subtract the date returned by TODAY() from the date returned by EOMONTH and apply the
General format to a cell:
=EOMONTH(TODAY(), 0)-TODAY()
How to find the first day of month in Excel
As you already know, Microsoft Excel provides just one function to return the last day of the
month (EOMONTH). When it comes to the first day of the month, there is more than one way to
get it.
Example 1. Get the 1st day of month by the month number
If you have the month number, then use a simple DATE formula like this:
=DATE(year, month number, 1)
For example, =DATE(2015, 4, 1) will return 1-Apr-15.
If your numbers are located in a certain column, say in column A, you can add a cell reference
directly in the formula:
=DATE(2015, B2, 1)
Example 3. Find the first day of month based on the current date
When your calculations are based on today's date, use a liaison of the Excel EOMONTH and
TODAY functions:
=EOMONTH(TODAY(),0) +1 - returns the 1st day of the following month.
As you remember, we already used a similar EOMONTH formula to get the last day of the
current month. And now, you simply add 1 to that formula to get the first day of the next month.
In a similar manner, you can get the first day of the previous and current month:
=EOMONTH(TODAY(),-2) +1 - returns the 1st day of the previous month.
the DAY / DATE formula discussed in the above example, and it will tell you how many days a
given month contains:
=DAY(DATE(YEAR(A2), MONTH(A2) +1, 1) -1)
Where A2 is cell with a date.
Alternatively, you can use a much simpler DAY / EOMONTH formula. As you remember,
the Excel EOMONTH function returns the last day of the month, so you don't need any
additional calculations:
=DAY(EOMONTH(A1, 0))
The following screenshot demonstrates the results returned by all of the formulas, and as you
see they are identical:
If you'd rather not add a helper column to your Excel sheet, no problem, you can do without it. A
bit more trickier SUMPRODUCT function will work a treat:
=SUMPRODUCT((MONTH($A$2:$A$15)=$E2) * ($B$2:$B$15))
Where column A contains dates, column B contains the values to sum and E2 is the month
number.
Note. Please keep in mind that both of the above solutions add up all values for a given month
regardless of the year. So, if your Excel worksheet contains data for several years, all of it will
be summed.
How to conditionally format dates based on month
Now that you know how to use the Excel MONTH and EOMONTH functions to perform various
calculations in your worksheets, you may take a step further and improve the visual
presentation. For this, we are going to use the capabilities of Excel conditional formatting for
dates.
In addition to the examples provided in the above mentioned article, now I will show you how
you can quickly highlight all cells or entire rows related to a certain month.
This is how the MONTH function in Excel works. It appears to be far more versatile than it looks,
huh?
In a couple of the next posts, we are going to calculate weeks and years and hopefully you will
learn a few more useful tricks. If you are interested in smaller time units, please check out the
previous parts of our Excel Dates series (you will find the links below). I thank you for reading
and hope to see you next week!
o
o
o
o
o
o
o
WEEKDAY(serial_number,[return_type])
Serial_number - a serial number that represents the date, or a reference to a cell with a
date or serial number.
If the term "serial number" does not make much sense to you, let me remind you that Excel
stores all dates as serial numbers beginning with January 1, 1900, which is stored as number 1.
And it is these numbers that the WEEKDAY function operates on. If you want to learn more
about how Excel stores dates and times, you may find the following article useful: Excel date
format.
Return_type (optional) - determines what day of the week to use as the first day in
calculations.
In your Excel WEEKDAY formulas, you can specify any of the following values for the
return_type argument:
Return_type
Number returned
1 or omitted
11
12
13
14
15
16
17
Note. Though the WEEKDAY function is available in all Excel versions, from Excel 2013 to
2000, the return_type values 11 through 17 were introduced in Excel 2010 only, therefore they
cannot be used in earlier versions.
And now, let's look at some examples of using the WEEKDAY function in Excel. All of the below
formulas return the day of the week corresponding to March 19, 2015. For the sake of clarity,
At first sight, it may seems that the numbers returned by the Excel WEEKDAY function have
very little practical sense. But let's look at it from a different angle and discuss some formulas
that solve real-life tasks.
Example 1. Excel WEEKDAY formula to find workdays and weekends
If you have a long date column in your worksheet, you may want to know which dates are
working days and which are weekends.
An easiest way is to have a day name displayed in a cell, for example as "Friday, March 20,
2015" or just "Friday". And you can do this in no time by simply changing the date format.
However, this is not always an ideal approach, firstly, because a short date format is often
required, and secondly, because you may need to filter only weekends or only workdays in your
Excel list.
One of possible solutions is embedding the WEEKDAY function into the logical test of the IF
function:
=IF(WEEKDAY(A2,2)<6, "Workday", "Weekend")
In this Weekday formula, we set the return_type argument to 2, which corresponds to the
week beginning with Monday (day 1). So, if the day of the week in cell A2 is less than 6
To filter weekdays or weekend days, you apply Excel's filter to your table (Data tab > Filter) and
select either "Workday" or "Weekend".
If your organization, or maybe some regional office of your company, works on a different
schedule where the days of rest are other than Saturday and Sunday, you can easily adjust this
WEEKDAY formula to your needs by specifying a different return_type .
For example, to treat Saturday and Monday as weekends, you set return_type to 12, since you
want the "Tuesday (1) to Monday (7)" week type:
=If(WEEKDAY(A2, 12)<6, "Weekday", "Weekend")
Please note that the results, which may look like usual text entries to you, are in fact fully
functional Excel dates that you can use in other calculations. You can tell these are dates by
their right alignment in a cell as opposed to left-aligned text values.
Example 4. Return day of week as a text value
An alternative way to determine a day of the week by date is using the Excel TEXT function. In
your TEXT formulas, you can specify the same formats as in the above example - "ddd" to
return a short name and "dddd" to return full names of the days of the week:
=TEXT(A1, "ddd")
=TEXT(A1,"dddd")
Where A1 is a cell with the original date.
When using this method, please remember that the TEXT function in Excel always returns text
strings regardless of the source cell's format. So, the day of week names you see in the above
screenshot are text entries, and not dates. And this is what makes them different from the
results of the previous example, which are still fully functional Excel dates.
In this formula, the Excel WEEKDAY function gets the day of week as a serial number. And the
CHOOSE function uses that number as index_num (the 1st argument) that indicates which
value from the list of value arguments to return.
How to get the day of month from date (DAY function)
Microsoft Excel provides a special DAY function to retrieve the day of the month from a date:
DAY(serial_number)
The day is returned as a serial number ranging from 1 to 31. For example, in you have a list of
dates in column A and you want to extract the days into column B, you put the following formula
in cell B2 and then copy it down to other cells:
=DAY(A2)
Note. The Excel DAY function correctly handles dates in different Date formats, though the
problems may occur if dates are entered as text. Please see How to distinguish normal Excel
dates from text dates for full details.
An alternative way to extract a day of the month from a date is using the TEXT function, for
example:
How to calculate the number of days between two dates (DAYS function)
The syntax of the Excel DAYS function is so obvious that you will hardly need any
explanations :)
DAYS(end_date, start_date)
Supposing that the Start Date of your projects is in column A and the End Date in column B, you
can calculate the projects' duration (i.e. the number of days between two dates) using the
following formula:
=DAYS(B2,A2)
This formula will work with normal dates as well as dates formatted as text. If either the start
date or end date is a text value, Excel will try to convert it to date (you would use the
DATEVALUE function for this). If Excel is unable to parse your text sting as a valid date, the
DAYS formula will return the #VALUE! error.
Working with days of the year in Excel
When working with days of year in Excel, you have a few functions at your disposal. Which one
to choose depends on your data format and exactly what result you are after :)
Example 1. Get the day number of the year (1-365)
This example demonstrates how you can get the number of a certain day in a year, between 1
and 365 (1-366 in leap years) with January 1 considered day 1.
For this, you use a combination of the Excel DATE and YEAR functions:
=A2-DATE(YEAR(A2),1,0)
Where A2 is a cell containing the date.
And now, let's see what the formula actually does. The YEAR function retrieves the year of the
date in cell A2, and passes it to the DATE(year, month, day) function, which returns the
sequential number that represents a certain date.
So, in our formula, year is extracted from the original date (A2), month is 1 (January)
and day is 0. In fact, a zero day forces Excel to return December 31 of the previous year,
because we want January 1 to be treated as the 1st day. And then, you subtract the serial
number returned by the DATE formula from the original date (which is also stored as a serial
number in Excel) and the difference is the day of the year you are looking for. For example,
January 5, 2015 is stored as 42009 and December 31, 2014 is 42004, so 42009 - 42004 = 5.
If the concept of day 0 does not seem right to you, you can use the following formula instead:
=A2-DATE(YEAR(A2),1,1)+1
If you want to know how many days remain till the end of the year based on the current date,
you use the Excel TODAY() function, as follows:
=DATE(2015,12,31)-TODAY()
Where 2015 is the current year.
This is how you work with days of week and days of year in Excel. In the next article, we will
explore Excel functions to operate on bigger time units such as weeks, months and years.
Please stay tuned and thank you for reading!
How to convert date to text using Excel TEXT function and no-formula ways
In the previous article, we discussed different ways to convert text to date in Excel. If you are
looking for a solution to the opposite task - changing an Excel date to text - a few choices are
available to you again.
Traditionally, we'll begin with a formula solution and then explore a couple of non-formula ways.
value is a numeric value you want to convert to text. This can be a number, a formula
that returns a numeric value, or a reference to a cell containing a number.
format_text this is how you want to format the resulting text value, provided as a text
string enclosed in quotation marks.
For example, you can use the following formula to convert a date in cell A1 to a text string in the
traditional US date format (month/day/year):
=TEXT(A1,"mm/dd/yyyy")
As you see in the screenshot above, the value returned by the TEXT formula is aligned to the
left, which is the first sign that points to a date formatted as text. Apart from alignment in a cell,
there are a few more indicators that can help you distinguish between dates and text strings in
Excel.
yy - two-digit year.
Yyyy - four-digit year.
To display the converted text date exactly the way you want, you can separate the date codes
with various delimiters such as dash (-), slash (/), comma (,) colon (:), etc. Here are a few
examples:
If you want to convert the time portion only, then put only the time codes, like this:
=TEXT(A2,"h:mm AM/PM")
The results of your TEXT formulas may look similar to this:
the same way with the only difference that you choose Text instead of Date on the final step of
the wizard.
Note. The Text to Column wizard always converts dates in the default short date
formatregardless of how the original dates are displayed in your worksheet. You can find more
about default date and time formats in the following article: Default date format in Excel.
If the default date format is not what you are looking for, you can jump right to the next
solutionthat lets you convert dates to text strings in any format of your choosing.
If you don't mind the default format, then perform the following steps:
1.
2.
In your Excel spreadsheet, select all of the dates you want to change to text.
On the Data tab, find the Data Tools group, and click Text to Columns.
3.
On step 1 of the wizard, select the Delimited file type and click Next.
4.
On step 2 of the wizard, make sure none of the delimiter boxes is checked and
click Next.
5.
On step 3 of the wizard, which is the final step, select Text under Column data
format and clickFinish.
Tip. If you don't want the resulting text strings to overwrite the original dates, specify
theDestination for the top cell of the new column.
That was really easy, right? The screenshot below demonstrates the result - dates converted to
text strings in the default short date format set in your Windows Regional settings, which is
"mm/dd/yyyy" in my case:
1.
In your Excel worksheet, format the dates exactly as you want the text strings to look
like.
2.
Select all of the dates you want to convert and press Ctrl+C to copy them.
3.
4.
Open Notepad or any other text editor, and paste the copied dates there.
Notepad automatically converts the dates to the text format. Press Ctrl+A to select all
text strings, and then Ctrl+C to copy them.
5.
Switch back to Microsoft Excel, select the column where you want to insert the text
strings and apply the Text format to it. To do this, press Ctrl+1 to open the Format
Cells dialog and selectText on the Number tab.
6.
Finally, select the first cell where you want to insert the text strings and press Ctrl+V to
paste them.
The following screenshot shows the result, with the original Excel dates in column B and text
entries in column D. Please notice that the converted text strings reflect the original date format
with absolute accuracy, except they are left-alighted, as all text values are supposed to be in
Excel.
This is how you convert date to text in Excel. Next week we will explorer a few Excel functions
to work with weekdays and days of the year. And in the meantime, you may want to check out
the previous parts of our comprehensive tutorial to working with dates and times in Excel.
o
o
o
o
o
o
o
Right-aligned by default.
Have Date format in the Number
Formatbox on the Home tab > Number
If several dates are selected, the Status
Bar shows Average, Count and SUM.
Text values
Left-aligned by default.
General format displays in
the Number Format box on
the Home tab > Number
If several text dates are
selected, the Status Bar only
shows Count.
There may be a leading
Yep, it's that easy! If you want something more sophisticated than predefined Excel date
formats, please see how to create a custom date format in Excel.
If some stubborn number refuses to change to a date, check out Excel date format not working troubleshooting tips.
How to convert text to date in Excel
When you spot text dates in your Excel file, most likely you would want to convert those text
strings to normal Excel dates so that you can reference them in your formulas to perform
calculations. And as is often the case in Excel, there are a few ways to tackle the task.
Excel DATEVALUE function - change text to date
The DATEVALUE function in Excel converts a date in the text format to a serial number that
Excel recognizes as a date.
Time information in text strings is ignored, as you can see in rows 6 and 8 above. To
convert text values containing both dates and times, use the VALUE function.
If the year is omitted in a text date, Excel's DATEVALUE will pick the current year from
your computer's system clock, as demonstrated in row 4 above.
Since Microsoft Excel stores dates since January 1, 1900 , the use of the Excel
DATEVALUE function on earlier dates will result in the #VALUE! error.
The DATEVALUE function cannot convert a numeric value to date, nor can it process a
text string that looks like a number, for that you will need to use the Excel VALUE function, and
this is exactly what we are going to discuss next.
Excel VALUE function - convert a text string to date
Compared to DATEVALUE, the Excel VALUE function is more versatile. It can convert any text
string that looks like a date or number into a number, which you can easily change to a date
format of your choosing.
The syntax of the VALUE function is as follows:
=VALUE(text)
Where <code>text</code> is a text string or reference to a cell containing the text you want to
convert to number.
The Excel VALUE function can process both date and time, the latter is converted to a decimal
portion, as you can see in row 6 in the following screenshot:
Addition: =A1 + 0
Multiplication: =A1 * 1
Division: =A1 / 1
Double negation: =--A1
As you can see in the above screenshot, mathematical operations can convert dates (rows 2
and 4), times (row 6) as well as numbers formatted as text (row 8). Sometimes the result is even
displayed as a date automatically, and you don't have to bother about changing the cell format.
Now, the DATEVALUE or VALUE function should have no problem with converting the text
strings to dates. In the same manner, you can fix dates containing any other delimiter, e.g. a
space or a backward slash.
If you prefer a formula solution, you can use Excel's SUBSTITUTE function instead of Replace
All to switch your delimiters to slashes.
Assuming the text strings are in column A, a SUBSTITUTE formula may look as follows:
=SUBSTITUTE(A1, ".", "/")
Where A1 is a text date and "." is the delimiter your strings are separated with.
Now, let's embed this SUBSTITUTE function into the VALUE formula:
=VALUE(SUBSTITUTE(A1, ".", "/"))
And have the text strings converted to dates, all with a single formula.
As you see, the Excel DATEVALUE and VALUE functions are quite powerful, but both have their
limits. For example, if you are trying to convert complex text strings like Thursday, January 01,
2015,neither function could help. Luckily, there is a non-formula solution that can handle this
task and the next section explains the detailed steps.
Text to Columns wizard - formula-free way to covert text to date
If you are a non-formula user type, a long-standing Excel feature called Text To Columns will
come in handy. It can cope with simple text dates demonstrated in Example 1 as well as multipart text strings shown in Example 2.
Example 1. Converting simple text strings to dates
If the text strings you want to convert to dates look like any of the following:
1/1/2015
1.2015
01 01 2015
2015/1/1
20150101
You don't really need formulas, nor exporting or importing anything. All it takes is 5 quick steps:
1.
2.
In your Excel worksheet, select a column of text entries you want to convert to dates.
Switch to the Data tab, Data Tools group, and click Text to Columns.
3.
In step 1 of the Convert Text to Columns Wizard, select Delimited and click Next.
4.
5.
In step 2 of the wizard, uncheck all delimiter boxes and click Next.
In the final step, select Date under Column data format, choose the
format corresponding to your dates, and click Finish.
In this example, we are converting the text dates formatted as "01 02 2015" (month day year),
so we select MDY from the drop down box.
Now, Excel recognizes your text strings as dates, automatically converts them to your default
date format and displays right-aligned in the cells. You can change the date format in the usual
way via the Format Cells dialog.
Note. For the Text to Column wizard to work correctly, all of your text strings should be
formatted identically. For example, if some of your entries are formatted
like day/month/yearformat while others are month/day/year, you would get incorrect results.
Example 2. Converting complex text strings to dates
If your dates are represented by multi-part text strings, such as:
4.
On step 2 of the wizard, select the delimiters your text strings contain.
For example, if you are converting strings separated by commas and spaces, like
"Thursday, January 01, 2015", you should choose both delimiters - Comma and Space.
It also makes sense to select the "Treat consecutive delimiters as one" option to ignore extra
spaces, if your data has any.
And finally, have a look at the Data preview window and verify if the text strings are split to
columns correctly, then click Next.
5.
On step 3 of the wizard, make sure all columns in the Data Preview section have
the Generalformat. If they don't, click on a column and select General under the Column
data formatoptions.
Note. Do not choose the Date format for any column because each column contains only
one component, so Excel won't be able to understand this is a date.
If you don't need some column, click on it and select Do not import column (skip).
If you don't want to overwrite the original data, specify where the columns should be inserted
- enter the address for the top left cell in the Destination field.
As you see in the screenshot above, we are skipping the first column with the days of the
week, splitting the other data into 3 columns (in the General format) and inserting these
columns beginning from cell C2.
The following screenshot shows the result, with the original data in column A and the split
data in columns C, D and E.
6.
Finally, you have to combine the date parts together by using a DATE formula. The
syntax of the Excel DATE function is self-explanatory:
Right-click the selection, click Paste Special, and select Add in the Paste Special dialog
box:
Clicking the exclamation mark will display a few options relevant to your data. In case of a 2digit year, Excel will ask if you want to convert it to 19XX or 20XX.
If you have multiple entries of this type, you can fix them all in one fell swoop - select all the
cells with errors, then click on the exclamation mark and select the appropriate option.
This is how you convert text to date in Excel and change dates to text. Hopefully, you have been
able to find a technique to your liking. In the next article, we will tackle the opposite task and
explore different ways of converting Excel dates to text strings. I thank you for reading and hope
to see you next week.
How to insert dates in Excel - add today's date, auto fill a column with dates
This tutorial demonstrates various ways of entering dates in Excel. See how to insert today's
date and current time as static or dynamic values, how to auto populate a column or row with
weekdays, and how to auto fill random dates in Excel.
There are several ways to add dates in Excel depending on what exactly you want to do. For
example, do you want to enter a today's date in some report or invoice? Or, perhaps you want
to insert a date in Excel that will update automatically and always display the current date and
time? Or, maybe you want to auto fill weekdays or input random dates in your worksheet?
In a moment, you will learn all these and a few more date entering techniques. If you are curious
to know how Excel stores dates and times, please check out part 1 of this tutorial - Excel date
format.
o
o
o
o
o
o
If Excel has failed to recognize your input as a date and you see it left-justified in a cell, try
inserting a date in some other format close to your default short or long date formats. These
formats are marked with an asterisk (*) in the Format Cell dialog window and you can quickly
access them on the Excel ribbon (Home tab > Number group):
You will be able to easily change the date format later via the Format Cells dialog that opens on
theCtrl + 1 shortcut. For more details, please see How to change the date format in Excel.
Note. If a date you've entered displays as a number of pound signs (#####) in a cell, most likely
the cell is not wide enough to fit the entire date. To fix this, double-click the right border of the
column to auto fit the date, or drag the right border to set the desired column width. If this does
not help, please check other Excel date format troubleshooting tips.
Inserting today's date and current time in Excel
In Microsoft Excel, you can input the current date and time either as a static or dynamic value.
Shortcuts to enter today date in Excel (as a timestamp)
To begin with, let's define what timestamp is. Timestamping is entering a "static date" that won't
change with the course of time or when the spreadsheet is recalculated.
So, if your goal is to enter the current date and/or time as a static value that won't automatically
update the next day, you can use one of the following shortcuts:
Unlike Excel date shortcuts, the TODAY and NOW functions will always return today's date and
current time.
When using the Excel date functions, please keep in mind that:
The returned date and time are not refreshed continuously, they are updated only when
the spreadsheet is re-opened or re-calculated, or when a macro containing the function is run.
The functions take the current date and time from your computer's system clock.
How to auto populate dates in Excel
If you need to insert dates in a range of cells, you can let Excel "auto date" a column or row by
using the AutoFill feature.
Auto fill a date series that increases by one day
To automatically fill a column or row with an incrementing date series that increases by one day,
you use Excel's AutoFill feature in the usual way:
You can use the Excel AutoFill options as described above. When the range is populated
with sequential dates, click the AutoFill Options icon and select the option you want:
2.
Another way is to enter your first date, select that cell, click the right mouse button and
drag the fill handle down the cells you want to auto fill with dates, and then release it. When
you do, Excel displays a context menu and you select the appropriate option from it.
Apart from dates, the Random Generator add-in can auto fill your worksheets with numbers,
Boolean vales and custom lists. If you think this is something that would be useful in your work,
we will gladly provide you with a 15% promotion code that we offer exclusively to our blog
readers: AB14-BlogSpo
This is how you insert date in Excel. I am hopeful these date entering techniques, shortcuts,
functions and Excel auto date features have proved useful to you. Anyway, thank you for
reading!
2 is 2-Jan-1900
3 is 3-Jan-1900
42005 is 1-Jan-2015 (because it is 42,005 days after January 1, 1900)
Time in Excel
Times are stored in Excel as decimals, between .0 and .99999, that represent a proportion of
the day where .0 is 00:00:00 and .99999 is 23:59:59.
For example:
0.25 is 06:00 AM
0.5 is 12:00 PM
0.541655093 is 12:59:59 PM
Dates & Times in Excel
Excel stores dates and times as decimal numbers comprised of an integer representing the date
and a decimal portion representing the time.
For example:
you want to replace the date with the number in a cell, click OK.
Note. Since Excel's serial numbers begins on January 1, 1900 and negative numbers aren't
recognized, dates prior to the year 1900 are not supported in Excel.
If you enter such a date in a sheet, say 12/31/1899, it will be a text value rather than a date,
meaning that you cannot perform usual date arithmetic on early dates. To make sure, you can
type the formula =DATEVALUE("12/31/1899") in some cell, and you will get an anticipated
result - the #VALUE! error.
Default date format in Excel
When you work with dates in Excel, the short and long date formats are retrieved from your
Windows Regional settings. These default formats are marked with an asterisk (*) in the Format
Cell dialog window:
The default date and time formats in the Format Cell box change as soon as you change the
date and time settings in Control Panel, which leads us right to the next section.
Tip. If you are not sure what different codes (such as mmm, ddd, yyy) mean, click the "What
does the notation mean" link under the Date and time formats section, or check the Custom
Excel date formats in this tutorial.
If you are not happy with any time and date format available on the Formats tab, click
theAdditional settings button in the lower right-hand side of the Region and Language dialog
window. This will open the Customize dialog, where you switch to the Date tab and enter a
custom short or/and long date format in the corresponding box.
On the Home tab, in the Number group, click the drop-down arrow and select the
desired formatting option - the default short date, long date and long time are available.
If you want more date formatting options, either select More Number Formats from the dropdown list or click the Dialog Box Launcher next to Number. This will open a familiar Format
Cells dialog and you can change date format there.
Tip. If you want to quickly set date format in Excel to dd-mmm-yy, press Ctrl+Shift+#. Just keep
in mind that this shortcut always applies the dd-mmm-yy format, like 01-Jan-15, regardless of
your Windows Region settings.
5. If you are happy for the preview, click the OK button to save the format change and close the
window.
If the date format is not changing in your Excel sheet, most likely your dates are formatted as
text and you have to convert them to the date format first.
How to convert date format to another locale
Once you've got a file full of foreign dates and you would most likely want to change them to the
date format used in your part of the world. Let's say, you want to convert an American date
format (month/day/year) to a European style format (day/month/year).
The easiest way to change date format in Excel based on how another language displays dates
is as follows:
If you want the dates to be displayed in another language, then you will have to create a custom
date format with a locale code.
Tip. The easiest way to set a custom date format in Excel is to start from an existing format
close to what you want. To do this, click Date in the Category list first, and select one of existing
formats under Type. After that click Custom and make changes to the format displayed in
theType box.
When setting up a custom date format in Excel, you can use the following codes.
Code
Description
mm
01
mmm
Jan
mmmm
January
mmmmm
dd
01
ddd
Mon
dddd
Monday
yy
05
yyyy
Year (4 digits)
2005
When setting up a custom time format in Excel, you can use the following codes.
Code
Description
Displays as
0-23
hh
00-23
0-59
mm
00-59
0-59
ss
00-59
AM/PM
AM or PM
Note. If you're setting up a custom format that includes date and time values and you use "m"
immediately after "hh" or "h" or immediately before "ss" or "s", Microsoft Excel will
displayminutes instead of the month.
When creating a custom date format in Excel, you can use a comma (,) dash (-), slash (/), colon
(:) and other characters.
For example, the same date and time, say January 13, 2015 13:03, can be displayed in a
various ways:
Format
Displays as
dd-mmm-yy
13-Jan-15
mm/dd/yyyy
01/13/2015
m/dd/yy
1/13/15
For example, this is how you set up a custom Excel date format for the Chinese locale in
the year-month-day (day of the week) time format:
The following image shows a few examples of the same date formatted with different locale
codes in the way traditional for the corresponding languages:
Of course, such representation is very unusual and takes time to get used to, but this is the right
way to go if you want to perform calculations with early dates.
Solution 2. Use the Excel TEXT function.
Another possible way to display negative numbers as negative dates in Excel is using the TEXT
function. For example, if you are subtracting C1 from B1 and a value in C1 is greater than in B1,
you can use the following formula to output the result in the date format:
=TEXT(ABS(B1-C1),"-d-mmm-yyyy")
You may want to change the cell alignment to right justified, and naturally, you can use any
othercustom date formats in the TEXT formula.
Note. Unlike the previous solution, the TEXT function returns a text value, that is why you won't
be able to use the result in other calculations.
Dates are imported to Excel as text values
When you are importing data to Excel from a .csv file or some other external database, dates
are often imported as text values. They may look like normal dates to you, but Excel perceives
them as text and treats accordingly.
Solution. You can convert "text dates" to the date format using Excel's DATEVALUE function or
Text to Columns feature. Please see the following article for full details: How to convert text to
date in Excel.
This is how you format dates in Excel. In the next part of our guide, we will discuss various ways
of how you can insert dates and times in your Excel worksheets. Thank you for reading and see
you next week!
=SUM((B2:B10>=A2:A10) * (B2:B10>0))
Remember to press Ctrl + Shift + Enter to enter the Excel array formula correctly.
The next couple of paragraphs are intended for those who like looking under the hood. If you
are not interested in tech details, you can skip right to the next formula example.
For better understanding of this formula in particular and Excel array formulas in general, let's
select the two expressions within the SUM function's parentheses in the formula bar, and
press F9 to view the arrays behind the formula parts. If you want more information on how
the F9key works, please check out Evaluating portions of an array formula with F9.
So, what we have here is two arrays of Boolean values, where TRUE equates to 1 and FALSE
equates to 0. Since we are using the AND array operator (*) in the formula, SUM will add up
only those rows that have TRUE (1) in both arrays, as shown in the screenshot below:
Note. Not all Excel functions that support arrays can convert TRUE and FALSE into 1 and 0. In
more complex array formulas, you would need to use a double dash (--), which is technically
called the double unary operator, to convert non-numeric Boolean values returned by the
formula's expressions into numbers.
Including a double dash in the above formula won't do any harm either, it will just keep you on
the safe side: =SUM(--(B2:B10>=A2:A10) * (B2:B10>0))
And here is a more sophisticated Excel array formula example that absolutely requires the use
of the double unary operator.
Example 2. Using several functions in Excel array formulas
Array formulas can work with several Excel functions at a time and perform multiple calculations
within a single formula.
For example, if you have a table listing multiple product sales by several salesmen, and you
want to know the maximum sale made by a given person for a given product, you can write an
array formula based on the following pattern:
=MAX(IF((salesmen_range="name") * (products_range="name"), sales_range,""))
Assuming that the sales person names are in column A, product names are in column B and
sales are in column C, the following formula returns the largest sale Mike has made for Apples:
=MAX(IF(($A$2:$A$9="mike") * ($B$2:$B$9="apples"), $C$2:$C$9,""))
Naturally, you can replace the names in the formula with cell references so that your users can
simply type the names in certain cells without modifying your array formula:
In the screenshot above, the following Excel array formulas are used (don't forget to press Ctrl +
Shift + Enter to enter them correctly):
Maximum: =MAX(IF(($A$2:$A$9=$F$1) * ($B$2:$B$9=$F$2), $C$2:$C$9,""))
Minimum: =MIN(IF(($A$2:$A$9=$F$1) * ($B$2:$B$9=$F$2), $C$2:$C$9,""))
Average: =AVERAGE(IF(($A$2:$A$9=$F$1) * ($B$2:$B$9=$F$2), $C$2:$C$9,""))
Total: =SUM(IF(($A$2:$A$9=$F$1) * ($B$2:$B$9=$F$2), $C$2:$C$9,""))
The MOD function returns the remainder rounded to the nearest integer after the number is
divided by the divisor. We embed the ROW function into it to get the row's number, and then
divide it by the Nth row (e.g. by 2 to sum every second cell) and check if the remainder is zero. If
it is, then the cell is summed.
The double unary operator (--) is used to convert non-numeric Boolean values TRUE and
FALSE returned by MOD into 1 and 0 for the SUM function to be able to add up the numbers.
For example, to count every other cell in range B2:B10, you use one of the following formulas:
Count even rows (2nd, 4th, etc.):
=SUM((--(MOD(ROW($B2:B10), 2)=0))*(B2:B10))
Count odd rows (1st, 3rd, etc.):
=SUM((--(MOD(ROW($B2:B10), 2)=1))*(B2:B10))
To get a universal formula that can sum values in any Nth rows that you specify and work
correctly with any ranges regardless of their location in a worksheet, the formula has to be
improved a little bit further:
=SUM((--(MOD((ROW($B$2:$B$7)-ROW($B$2)), E1)=E1-1))*($B$2:$B$7))
Where E1 is every Nth row you want to sum.
And now, let's see how you can use the GetCellColor function in an array formula. Suppose you
have a table with a color coded column and you want to sum the values that meet several
conditions, including a cell's color. As an example, let's find the total of "green" and "yellow"
sales made by Neal:
As demonstrated in the image above, we use the following Excel array formula:
=SUM(--($A$2:$A$10=$F$1) * ($C$2:$C$10) * (-(GetCellColor($C$2:$C$10)=GetCellColor($E$2))))
Where cell F1 is the sales person name and E2 is the color pattern.
The formula sums cells in the range C2:C10 if the following 2 conditions are met:
$A$2:$A$10=$F$1 - checks if a cell in column A matches the seller name in F1, which
isNeal in this example.
GetCellColor($C$2:$C$10)=GetCellColor($E$2) - we use the custom user-defined
function to get the color of cells C2 through C10, and check if it matches the color pattern in E2,
green in this case.
Please pay attention that we use the double unary operator with both of the above expressions
in order to convert the Boolean values TRUE and FALSE they return into 1's and 0's the SUM
function can operate on. If both conditions are met, i.e. two 1's are returned, SUM adds up the
sales amount from a corresponding cell in column C.
More Excel array formula examples
And here are a few more examples of Excel array formulas that might be helpful.
Look up with multiple criteria - a powerful INDEX / MATCH function that can look up by
values in 2 different columns.
Get all duplicate values in the lookup range - how to get all instances of the lookup
value.
Case-sensitive lookup for all data types - self-explanatory : )
Array LOOKUP and SUM - how to look up in an array and sum all matching values.
Excel SUM function in array formulas - a few examples that demonstrate the uses of
SUM in array formulas.
Excel TRANSPOSE formula examples - how to convert rows to columns in Excel.
Sum the largest or smallest numbers in a range - how to sum a variable number of
largest / smallest values in the range.
Excel array formulas - limitations and alternatives
Array formulas are by far one of the most powerful features in Excel, but not all-powerful. Here
are the most critical limitations of arrays in Excel.
1. Large arrays may slow down Excel
Though Microsoft Excel does not impose any limit on the size of arrays you use in your
worksheets, you are limited by memory available on your computer because recalculating
formulas with large arrays is time consuming. So, in theory, you can create huge arrays
consisting of hundreds or thousands of elements, in practice this is not recommended because
they can drastically slow your workbooks.
2. Entire column arrays are not allowed
You are not allowed to create an array that includes a whole column or several columns for an
obvious reason explained above. Array formulas in Excel are very resource-hungry and
Microsoft is taking preventive measures against Excel's freezing.
3. Limit to array formulas referring to another sheet
In Excel 2003 and earlier versions, a given worksheet could contain a maximum of 65,472 array
formulas referring to another sheet. In modern versions of Excel 2013, 2010 and 2007, crossworksheet array formulas are limited by available memory only.
4. Debugging array formulas
If your array formula returns an incorrect result, make sure you pressed Ctrl + Shift +
Enter when entering it. If you did, select parts of the formula and press the F9 to evaluate and
debug them.
5. Alternatives to array formulas.
If you find Excel array formulas too complex and confusing, you can use one of Excel functions
that can naturally process arrays of data (without pressing Ctrl + Shift + Enter). A good example
is the SUMPRODUCT function that multiplies values in the specified arrays and returns the sum
of those products. Another example is Excel INDEX function with an empty value or 0 in the
row_num or col_num argument to return an array of values from the entire column or row,
respectively.
If you want to download the Excel array formula examples discussed in this tutorial to reverseengineer them for better understanding, you are most welcome to download formula examples.
This is an .xlsm file since example 6 includes a custom VBA function, so you will have to click
theEnable Content button after downloading to allow the macro to run.
That's all for today, thank you for reading!
What you have just done is create a one-dimensional horizontal array. Nothing dreadful so far,
right?
Now, what is an Excel array formula? The difference between an array formula and regular
Excel formulas is that an array formula processes several values instead of just one. In other
words, an array formula in Excel evaluates all individual values in an array and performs
multiple calculations on one or several items according to the conditions expressed in the
formula.
Not only can an array formula deal with several values simultaneously, it can also return several
values at a time. So, the results returned by an Excel array formula is also an array.
Array formulas are available in all versions of Excel 2013, Excel 2010, Excel 2007 and lower.
And now, it seems to be the right time for you to create your first array formula.
Simple example of Excel array formula
Suppose you have some items in column B, their prices in column C, and you want to calculate
the grand total of all sales.
Of course, nothing prevents you from calculating subtotals in each row first with something as
simple as =B2*C2 and then sum those values:
However, an array formula can spare you those extra key strokes since it gets Excel to store
intermediate results in memory rather than in an additional column. So, all it takes is a single
array formula and 2 quick steps:
1. Select an empty cell and enter the following formula in it:
=SUM(B2:B6*C2:C6)
2. Press CTRL + SHIFT + ENTER to complete the array formula.
Once you do this, Microsoft Excel surrounds the formula with {curly braces}, which is a visual
indication of an array formula.
What the formula does is multiply the values in each individual row of the specified array (cells
B2 through C6), add the sub-totals together, and outputs the grand total:
This simple example shows how powerful an Excel array formula can be. When working with
hundreds and thousands of rows of data, just think how much time you can save by entering
one array formula in a single cell.
Why use array formulas in Excel?
Excel array formulas are the handiest tool to perform sophisticated calculations and do complex
tasks. A single array formula can replace literally hundreds of usual formulas. Array formulas are
very good for tasks such as:
Sum numbers that meet certain conditions, for example sum N largest or smallest
values in a range.
Sum every other row, or every Nth row or column, as demonstrated in this example.
Count the number of all or certain characters in a specified range. Here is an array
formula thatcounts all chars, and another one that counts any given characters.
How to enter array formula in Excel (Ctrl + Shift + Enter)
You already know that to enter an array formula in Excel, CTRL + SHIFT + ENTER shortcut is
required. This is a magic touch that turns a regular formula into an array formula.
There are 4 important things to keep in mind:
1. Once you've finished typing the formula and pressed Ctrl + Shift + Enter, Excel automatically
encloses the formula between {curly braces}. When you select such a cell(s), you can see the
braces in the formula bar, which gives you a clue that an array formula is in there.
2. Manually typing the braces around a formula won't convert it into an array formula. You must
press Ctrl + Shift + Enter to complete an array formula.
3. Every time you edit an array formula, the braces disappear and you must press Ctrl + Shift +
Enter again to save the changes in your formula.
4. If you forget to press Ctrl + Shift + Enter, your formula will behave like a usual Excel formula
and process only the first value(s) in the specified array(s).
Because all Excel array formulas require pressing Ctrl + Shift + Enter, they are sometimes
calledCSE formulas.
Use the F9 key to evaluate portions of an array formula
When working with array formulas in Excel, you can observe how they calculate and store their
items (internal arrays) to display the final result you see in a cell. To do this, select one or
several arguments within a function's parentheses, and then press the F9 key.
In the above example, to see the sub-totals of all products, you select B2:B6*C2:C6,
press F9 and get the following result.
Note. Please pay attention that you must select some part of the formula prior to pressing F9,
otherwise the F9 key will simply replace your Excel array formula with the calculated value(s).
Single-cell and multi-cell array formulas in Excel
Excel array formulas can return a result in a single cell or in multiple cells. An array formula
entered in a range of cells is called a multi-cell formula. An array formula residing in a single
cell is called a single-cell formula.
There exist a few Excel array functions that are designed to return multi-cell arrays, for example
TRANSPOSE, TREND, FREQUENCY, LINEST, etc.
Other functions, such as SUM, AVERAGE, AGGREGATE, MAX, MIN, can calculate array
expressions when entered into a single cell by using Ctrl + Shift + Enter.
The following examples demonstrate how to use a single-cell and multi-cell array formula in
Excel.
Once you press Ctrl + Shift + Enter, Excel will place an instance of your array formula in each
cell of the selected range, and you will get the following result:
This is how you use an array function in Excel. To learn the nuts and bolts of Excel
TRANSPOSE, please check out this tutorial: How to transpose in Excel - convert rows to
columns.
How to work with multi-cell array formulas
When working with multi-cell array formulas in Excel, be sure to follow these rules to get the
correct results:
1. Select the range of cells where you want to output the results before entering the formula.
2. To delete a multi-cell array formula, either select all the cells containing it and press DELETE,
or select the entire formula in the formula bar, press DELETE, and then press Ctrl + Shift +
Enter.
3. You cannot edit, move or delete the contents of an individual cell in an Excel array formula.
Nor can you insert new cells into or delete existing cells from a multi-cell array formula.
Whenever you try doing this, Microsoft Excel will throw the warning "You cannot change part of
an array".
4. To shrink an array formula, i.e. to apply it to fewer cells, you need to delete the existing
formula first and then enter a new one.
5. To expand an array formula, i.e. apply it to more cells, select all cells containing the current
formula plus empty cells where you want to have it, press F2 to switch to the edit mode, adjust
the references in the formula and press Ctrl + Shift + Enter to update it.
As you see in the screenshot, Microsoft Excel wraps an array constant in another set of braces,
exactly like it does when you are entering an array formula in Excel.
2. Vertical array constant
A vertical array constant resides in a column. You create it in the same way as a horizontal array
with the only difference that you delimit the items with semicolons, for example:
Switch to the Formulas tab > Defined Namesgroup and click Define Name. Alternatively,
press Crtl + F3 and click New.
Type the name in the Name
In the Refers tobox, enter the items of your array constant surrounded in braces with the
preceding equality sign (=). For example:
={"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
3. Preventing errors
If your array constant does not work correctly, check for the following problems:
Delimit the elements of your array constant with the proper character - comma in
horizontal array constants and semicolon in vertical ones.
Selected a range of cells that exactly matches the number of items in your array
constant. If you select more cells, each extra cell will have the #N/A error. If you select fewer
cells, only a part of the array will be inserted.
Using array constants in Excel formulas
Now that you are familiar with the concept of array constants, let's see how you can use arrays
in Excel formulas to solve your practical tasks.
In a similar fashion, you can calculate the average of N smallest or largest values in a range:
Average of the top 3 numbers: =AVERAGE(LARGE(range, {1,2,3}))
Average of the bottom 3 numbers: =AVERAGE(SMALL(range, {1,2,3}))
Example 2. Array formula to count cells with multiple conditions
Suppose, you have a list of orders and you want to know how many times a giver seller has sold
given products.
The easiest way would be using a COUNTIFS formula with multiple conditions. However, if you
want to include many products, your COUNTIFS formula may grow too big in size. To make it
more compact, you can use COUNTIFS together with SUM and include an array constant in
one or several arguments, for example:
=SUM(COUNTIFS(range1, "criteria1", range2, {"criteria1", "criteria2"}))
Our sample array consists of only two elements since the goal is to demonstrate the approach.
In your real array formulas, you may include as many elements as your business logic requires,
provided that the total length of the formula does not exceed 8,192 characters in Excel 2013,
2010 and 2007 (1,024 characters in Excel 2003 and lower) and your computer is powerful
enough to process large arrays. Please see the limitations of array formulas in Excel for more
details.
And here is an advanced Excel array formula example that finds the sum of all matching values
in a table: SUM and VLOOKUP with an array constant.
AND and OR operators in Excel array formulas
An array operator tells the formula how you want to process the arrays - using AND or OR logic.
AND operator is the asterisk (*). It is used to return a value if ALL of the conditions
specified in your array formula evaluate to TRUE.
OR operator is the plus sign (+). You use it to return a value if ANY of the conditions in a
given expression evaluates to TRUE.
Array formula with the AND operator
In this example, we find the sum of sales where the sales person is Mike AND the product
isApples:
=SUM((A2:A9="Mike") * ( B2:B9="Apples") * ( C2:C9))
Or
Tip. In modern versions of Excel 2013, 2010 or 2007, the use of array formulas in such
scenarios is actually superfluous and a simple SUMIFS formula could produce exactly the same
results. Nevertheless, the AND and OR operators in array formulas may prove helpful in other
more complex scenarios, let alone very good gymnastics of mind : )
Double unary operator in Excel array formulas
If you've ever worked with array formulas in Excel, chances are you came across a few ones
containing a double dash (--) and you may have wondered what it was used for.
A double dash, which is technically called the double unary operator, is used to convert nonnumeric Boolean values (TRUE / FALSE) returned by some expressions into 1 and 0 that an
Excel array function can understand.
The following example will hopefully make things easier to understand. Suppose you have a list
of dates in column A and you want to know how many dates occur in January, regardless of the
year.
The following formula will work a treat:
=SUM(--(MONTH(A2:A10)=1))
Since this is an Excel array formula, remember to press Ctrl + Shift + Enter to complete it.
If you are interested in some other month, replace 1 with a corresponding number. For example,
2 stands for February, 3 means March, and so on. To make the formula more flexible, you can
specify the month number in some cell, like demonstrated in the screenshot:
And now, let's analyze how this Excel array formula works. The MONTH function returns the
month of each date in cells A2 through A10 represented by a serial number, which producing the
array {2;1;4;2;12;1;2;12;1}.
After that, each element of the array is compared to the value in cell D1, which is number 1 in
this example. The result of this comparison is an array of Boolean values TRUE and FALSE. As
you remember, you can select a certain portion of an array formula and press F9 to see what
that part equates to:
Finally, you have to convert these Boolean values to 1's and 0's that the SUM function can
understand. And this is what the double unary operator is needed for. The first unary coerces
TRUE/FALSE to -1/0, respectively. The second unary negates the values, i.e. reverses the sign,
turning them into +1 and 0, which most of Excel functions can understand and work with. If you
remove the double unary from the above formula, it won't work.
I am hopeful this short tutorial has proved helpful on your road to mastering Excel array
formulas. Next week, we are going to continue with Excel arrays by focusing on advanced
formula examples. Please stay tuned and thank you for reading!
Here A2:D10 is your range with data and "*" is a wildcard matching any number of characters.
Just enter the formula with the correct range to any cell where you want to see the result and
press Enter. The result will be right there.
Note. The logical values TRUE and FALSE are not counted as text. In addition, numbers are
not counted by "*" if they are not entered as text starting with an apostrophe ('). Empty cells
beginning with an apostrophe (') will be counted.
One more formula you can use to count cells with text in Excel is
=COUNTA(RANGE)-COUNT(RANGE).
Thus if you need to quickly count cells with text in Excel, feel free to use one of the formulas
above.
Excel formula to count characters in a cell
I can presume that in one of the future versions of Excel the Status Bar will show the number
characters in a string. While we are hoping and waiting for the feature, you can use the following
simple formula:
=LEN(A1)
In this formula A1 is the cell where the number of text characters will be calculated.
The point is Excel has character limitations. For example, the header cannot exceed 254
characters. If you exceed the maximum, the header will be cut. The formula can be helpful when
you have really long strings in your cells and need to make sure that your cells don't exceed 254
characters to avoid problems with importing or displaying your table in other sources.
Thus, after applying the function =LEN(A1) to my table, I can easily see the descriptions that are
too long and need to be shortened. Thus, feel free to use this formula in Excel each time you
need to count the number of characters in a string. Just create the Helper column, enter the
formula to the corresponding cell and copy it across your range to get the result for each cell in
your column.
Excel - Count characters in several cells
You may also need to count the number of characters from several cells. In this case you
can use the following formula:
=SUM(LEN(RANGE))
Note. The above formula must be entered as an array formula. To enter it as an array formula,
press Ctrl+Shift+Enter.
This formula can be helpful if you want to see if any rows exceed the limitations before merging
or importing your data tables. Just enter it to the Helper column and copy across using the fill
handle.
Excel formula to count certain characters in a cell
In this part, I'll show you how to calculate the number of times a single character occurs in a cell
in Excel. This function really helped me when I got a table with multiple IDs that couldn't contain
more than one zero. Thus, my task was to see the cells where zeros occurred and where there
were several zeros.
If you need to get the number of occurrences of certain character in a cell or if you want to see if
your cells contain invalid characters, use the following formula to count the number of
occurrences of a single character in a range:
=LEN(A1)-LEN(SUBSTITUTE(A1,"a",""))
What I really like about this formula is that it can count the occurrences of a single character as
well as part of some text string.
Count the number of occurrences of certain character in a range
If you want to count the number of occurrences of certain character in several cells or in
one column, you can create a Helper column and paste there the formula I described in the
previous part of the article =LEN(A1)-LEN(SUBSTITUTE(A1,"a","")). Then you can copy it
across the column, sum this column and get the expected result. Sounds too time consuming,
doesn't it?
Fortunately, Excel often gives us more than one way to get the same result and there is a more
simple option. You can count the number of certain characters in a range using this array
formula in Excel:
=SUM(LEN(RANGE)-LEN(SUBSTITUTE(RANGE,"a","")))
Note. The above formula must be entered as an array formula. Please make sure you
press Ctrl+Shift+Enter to paste it.
Thus, if you have certain text snippet scattered around your table and need to count its
occurrences really quickly, use the formula above.
Excel character limits for cells
If you have worksheets with large amount of text in several cells, you may find the following
information helpful. The point is that Excel has a limitation on the number of characters you can
enter to a cell.
Thus, the total number of characters that a cell can contain is 32,767.
A cell can display only 1,024 characters. At the same time, the Formula bar can show
you all 32,767 symbols.
The maximum length of formula contents is 1,014 for Excel 2003. Excel 2007-2013 can
contain 8,192 characters.
Please consider the facts above when you have long headers or when you are going to merge
or import your data.
Count cells that contain specific text
If you need to count the number of cells that contain certain text, feel free to use the COUNTIF
function. You will find it beautifully described in COUNTIF formulas with wildcard characters
(partial match).
You may also be interested in
We have already written about counting and calculating in Excel. If you haven't found the
necessary information please have a look at one of the following articles published on our blog.
3 ways to count empty cells in Excel. In this post, you'll find quick tips for counting blank
cells in your table.
Learn how to count non-empty cells in Excel if you need to see the number of nonblanks in your worksheet.
COUNTIF in Excel - count if not blank, greater than, duplicate or unique. This article
focuses on the Excel COUNTIF function designed for counting cells with the condition you
specify.
If your task is to calculate cells by color, feel free to read how to count and sum cells by
color in Excel 2010 and 2013.
Last but not least, explore the possibilities of Excel COUNTIFS and COUNTIF with
multiple criteria.
Hope this article will help you next time you need to count the number of cells with text or
certain character occurrences in your spreadsheet. I tried to cover all options that can help you I described how to count cells with text, showed you an Excel formula for counting characters in
one cell or in a range of cells, you found how to count the number of occurrences of certain
characters in a range. Also you can benefit from one of the links to our previous posts to find
many additional details.
o
o
o
o
o
o
To get an idea of how the Excel INDEX formula works on real data, please have a look at the
following example:
Instead of entering the row and column numbers in the formula, you can supply the cell
references to get a more universal formula: =INDEX($B$2:$D$6, G2, G1)
So, this INDEX formula returns the number of items exactly at the intersection of the product
number specified in G2 (row_num) and week number entered in cell G1 (column_num).
Tip. The use of absolute references ($B$2:$D$6) instead of relative references (B2:D6) in the
array argument makes it easier to copy the formula to other cells. Alternatively, you can convert
a range to a table (Ctrl + T) and refer to it by the table name.
INDEX array form - things to remember
1. If the array argument consists of only one row or column, you may or may not specify the
corresponding row_num or column_num argument.
2. If the array argument includes more than one row and row_num is omitted or set to 0, the
Excel INDEX function returns an array of the entire column. Similarly, if array includes more
than one column and the column_num argument is omitted or set to 0, the INDEX formula
returns the entire row. Here's a formula example that demonstrates this behavior.
3. The row_num and column_num arguments must refer to a cell within array; otherwise, the
INDEX formula will return the #REF! error.
INDEX reference form
The reference form of the Excel INDEX function returns the cell reference at the intersection of
the specified row and column.
If each range in reference contains only one row or column, the corresponding row_num or
column_num argument is optional.
row_num - the row number in the range from which to return a cell reference, it's similar
to the array form.
column_num - the column number from which to return a cell reference, also works
similarly to the array form.
area_num - an optional parameter that specifies which range from the reference
argument to use. If omitted, the INDEX formula will return the result for the first range listed in
reference.
For example, the formula =INDEX((A2:D3, A5:D7), 3, 4, 2) returns the value of cell D7, which is
at the intersection of the 3rd row and 4th column in the second area (A5:D7).
Source data
All of our Excel INDEX formulas (except for the last one), we will use the below data. For
convenience purposes, it is organized in a table named SourceData.
The use of tables or named ranges can make formulas a bit longer, but it also makes them
significantly more flexible and better readable. To adjust any INDEX formula for your
worksheets, you need only to modify a single name, and this fully makes up for a longer formula
length.
Of course, nothing prevents you from using usual ranges if you want to. In this case, you simply
replace the table name SourceData with the appropriate range reference.
1. Getting the Nth item from the list
This is the basic use and the easiest Excel INDEX function example. To fetch a certain item
from the list, you just write =INDEX(range, n) where range is a range of cells or a named range,
and n is the position of the item you want to get.
When working with Excel tables, you can select the column using the mouse and Excel will pull
the column's name along with the table's name in the formula:
To get a value of the cell at the intersection of a given row and column, you use the same
approach with the only difference that you specify both - the row number and the column
number. In fact, you already saw such a formula in action when we discussed INDEX array
form.
And here's one more example. In our sample table, to find the 2nd biggest planet in the Solar
system, you sort the table by the Diameter column, and use the following INDEX formula:
=INDEX(SourceData, 2, 3)
your Excel INDEX formula more versatile, as demonstrated in the screenshot below:
In the above formula, the column_num argument is 4 because Temperature in the 4th column in
our table. The row_num parameter is omitted.
In a similar manner, you can find the minimum and maximum temperatures:
=MAX(INDEX(SourceData, , 4))
=MIN(INDEX(SourceData, , 4))
And calculate the total planet mass (Mass is the 2nd column in the table):
=SUM(INDEX(SourceData, , 2))
From practical viewpoint, the INDEX function in the above formula is superfluous. You can
simply write =AVERAGE(range) or =SUM(range) and get the same results.
When working with real data, this feature may prove helpful as part of more complex formulas
you use for data analysis.
3. Using INDEX with other Excel functions (SUM, AVERAGE, MAX, MIN)
From the previous examples, you might be under an impression that an INDEX formula in Excel
returns values, but the reality is that it returns a reference to the cell containing the value. And
this example demonstrates the true nature of the Excel INDEX function.
Since the result of an INDEX formula is a reference, we can use it within other functions to
make adynamic range. Sounds confusing? The following formula will make everything clear.
Suppose you have a formula =AVERAGE(A1:A10) that returns an average of the values in cells
A1:A10. Instead of writing the range directly in the formula, you can replace either A1 or A10, or
both, with INDEX functions, like this:
=AVERAGE(A1 : INDEX(A1:A20,10))
Both of the above formulas will deliver the same result because the INDEX function also returns
a reference to cell A10 (row_num is set to 10, col_num omitted). The difference is that the range
is the AVERAGE / INDEX formula is dynamic, and once you change the row_num argument in
INDEX, the range processed by the AVERAGE function will change and the formula will return a
different result.
Apparently, the INDEX formula's route appears overly complicated, but it does have practical
applications, as demonstrated in the following examples.
Example 1. Calculate average of the top N items in the list
Let's say you want to know the average diameter of the N biggest planets in our system. So,
you sort the table by Diameter column from largest to smallest, and use the following Average /
Index formula:
=AVERAGE(C5 : INDEX(SourceData[Diameter], B1))
calculates the number of non-empty cells in the column and ensures that only cells with data are
included in the named range.
The following screenshot demonstrates how you can use such Index formula to create
a dynamic drop-down list.
Tip. The easiest way to create a dynamically updated drop-down list in Excel is making anamed
list based on a table. In this case, you won't need any complex formulas since Excel tables are
dynamic ranges per se.
You can also use the INDEX function in Excel to create dependent drop-down lists and the
following tutorial explains the steps: Making a cascading drop-down list in Excel.
For more tips and formula example, please see the Excel INDEX / MATCH tutorial.
I hope the above image explains the reasoning behind the ranges' names : ) BTW,
the Moons table is far from complete, there are 176 known natural moons in our Solar System,
Jupiter alone has 63 currently, and counting. For this example, I picked random 11, well...
maybe not quite random - moons with the most beautiful names : )
Please excuse the digression, back to our Excel INDEX formula. Assuming that PlanetsD is
your range 1 and MoonsD is range 2, and cell B1 is where you put the range number, you can
use the following Index formula to calculate the average of values in the selected named range:
=AVERAGE(INDEX((PlanetsD, MoonsD), , , B1))
Please pay attention that now we are using the Reference form of the INDEX function, and the
number in the last argument (area_num) tells the formula which range to pick.
In the screenshot below, area_num (cell B1) is set to 2, so the formula calculates the average
diameter of Moons because the range MoonsD comes 2nd in the reference argument.
If you work with multiple lists and don't want to bother remembering the associated numbers,
you can employ a nested IF function to do this for you:
=AVERAGE(INDEX((PlanetsD, MoonsD), , , IF(B1="planets", 1, IF(B1="moons", 2))))
In the IF function, you use some simple and easy-to-remember list names that you want your
users to type in cell B1 instead of numbers. Please keep this in mind, for the formula to work
correctly, the text in B1 should be exactly the same (case-insensitive) as in the IF's parameters,
otherwise your Index formula will throw the #VALUE error.
To make the formula even more user-friendly, you can use Excel Data Validation to create
a drop-down list with predefined names to prevent spelling errors and misprints:
Finally, to make your INDEX formula absolutely perfect, you can enclose it in the IFERROR
functionthat will prompt the user to choose an item from the drop-down list if no selection has
been made yet:
=IFERROR(AVERAGE(INDEX((PlanetsD, MoonsD), , , IF(B1="planet", 1, IF(B1="moon",
2)))), "Please select the list!")
This is how you use INDEX formulas in Excel. I am hopeful these examples showed you a way
to harness the potential of the Excel INDEX function in your worksheets. Thank you for reading!
So, what is OFFSET in Excel? In a nutshell, the OFFSET formula returns a reference to a range
that is offset from a starting cell or a range of cells by a specified number of rows and columns.
The Excel OFFSET function may be a bit tricky to get, so let's go over a short technical
explanation first (I'll do my best to keep it simple) and then we will cover a few of the most
efficient ways to use OFFSET in Excel.
o
o
o
o
Required arguments:
Reference - a cell or a range of adjacent cells from which you base the offset. You can
think of it as the starting point.
Rows - The number of rows to move from the starting point, up or down. If rows is a
positive number, the formula moves below the starting reference, in case of a negative number
it goes above the starting reference.
Cols - The number of columns you want the formula to move from the starting point. As
well as rows, cols can be positive (to the right of the starting reference) or negative (to the left of
the starting reference).
Optional arguments:
Height - the height, in number of rows, of the returned reference.
Width - the width, in number of columns, of the returned reference.
Both the height and width arguments must always be positive numbers. If either is omitted, the
height or width of the starting reference is used.
And now, let's illustrate the theory with an example of the simplest OFFSET formula.
Excel OFFSET formula example
The following OFFSET formula returns a cell reference based on a starting point, rows and cols
that you specify:
=OFFSET(A1,3,1)
The formula tells Excel to take cell A1 as the starting point (reference), then move 3 rows down
(rows argument) and 1 column to the left (cols argument). As the result, this OFFSET formula
returns the value in cell B4.
The image on the left shows the function's route and the screenshot on the right demonstrates
how you can use the OFFSET formula on real-life data. The only difference between the two
formulas is that the second one (on the right) includes a cell reference (E1) in the rows
argument. But since cell E1 contains number 3, and exactly the same number appears in the
rows argument of the first formula, both would return an identical result - the value in B4.
formula each time manually or have the Excel OFFSET formula do this for you.
Since the first cell of the range to sum will be specified directly in the SUM formula, you only
have to decide on the parameters for the Excel OFFSET function, which will get that last cell of
the range:
The following details can help you understand the formulas better:
Reference - the header of the column whose values you want to sum, cell B1 in this
example.
Rows - to calculate the number of rows to offset, you use either the COUNT or COUNTA
function.
COUNT returns the number of cells in column B that contain numbers, from which you subtract
the last N months (the number is cell E1), and add 1.
If COUNTA is your function of choice, you don't need to add 1, since this function counts all nonempty cells, and a header row with a text value adds an extra cell that our formula needs.
Please note that this formula will work correctly only on a similar table structure - one header
row followed by rows with numbers. For different table layouts, you may need to make some
adjustments in the OFFSET/COUNTA formula.
The key benefit of these formulas over the usual AVERAGE(B5:B8) or MAX(B5:B8) is that you
won't have to update the formula every time your source table gets updated. No matter how
many new rows are added or deleted in your Excel worksheet, the OFFSET formulas will
always refer to the specified number of last (lower-most) cells in the column.
Reference is expressed as the sheet name followed by the exclamation mark and the
address of the cell containing the first item to be included in the named range. Please note the
use of the absolute cell references (with the $ sign), for example Sheet1!$A$1.
Rows and Cols parameters are both 0, since there are no columns or rows to offset.
Height is the key point that does the trick. You use the COUNTA function to calculate the
number of non-blank cells in the column containing the named range's items. Please pay
attention that in COUNTA's parameter, you should specify the sheet name in addition to the
column name, e.g. COUNTA(Sheet_Name!$A:$A).
Width is 1 column.
Once you've created a dynamic named range with the above OFFSET formula, you can use
Excel Data Validation to make a dynamic dropdown list that will update automatically as soon
For the detailed step-by-step guidance on creating drop-down lists in Excel, please check out
the following tutorials:
To handle a left-side lookup, you need a more versatile function that does not really care where
the return column resides. One of possible solutions is using a combination of INDEX and
MATCH functions. Another approach is using OFFSET, MATCH and ROWS:
=OFFSET(lookup table, MATCH(lookup value, OFFSET(lookup table, 0, 1, ROWS(lookup
table), 1) ,0) -1, 0, 1, 1)
In our example, the lookup table is A5:B9 and the lookup value is in cell B1, so the above
formula evolves into:
=OFFSET(A5:B9, MATCH(B1, OFFSET(A5:B9, 0, 1, ROWS(A5:B9), 1) ,0) -1, 0, 1, 1)
Of course, this lengthy OFFSET formula is not the only possible way to do a double lookup in
Excel. You can get the same result by using the VLOOKUP & MATCH functions,
SUMPRODUCT, or INDEX & MATCH. There is even a formula-free way - to employ named
ranges and the intersection operator (space). The following tutorial explains all alternative
solutions in full detail: How to do two-way lookup in Excel.
range of cells.
o
o
o
o
o
o
o
o
ref_text - is a cell reference, or a reference to a cell in the form of a text string, or a named
range.
a1 - is a logical value that specifies what type of reference is contained in the ref_text argument:
The INDIRECT function refers to the value in cell C1, which is A1.
The function is routed to cell A1 where it picks the value to return, which is number 3.
So, what the INDIRECT function actually does in this example is converting a text string into
a cell reference.
If you think this still has very little practical sense, please bear with me and I will show you some
more formulas that reveal the real power of the Excel INDIRECT function.
How to use INDIRECT in Excel - formula examples
As demonstrated in the above example, you can use the Excel INDIRECT function to put the
address of one cell into another as a usual text string, and get the value of the 1st cell by
referencing the 2nd. However, that trivial example is no more than a hint at the INDIRECT
capabilities.
When working with real data, the INDIRECT function can turn any text string into a reference
including very complex strings that you build using the values of other cells and results returned
by other Excel formulas. But let's not put the cart before the horse, and run through several
Excel Indirect formulas, one at a time.
As you see in the screenshot above, three different Indirect formulas return the same result.
Have you already figured out why? I bet you have : )
grabs the value in cell C5 (R3C) and turns it into the cell address C3 (row 3 in the same column)
and then gets forwarded to the known route.
However, if the value in cell C5 were R3C3 rather than R3C, the same formula would return the
value in cell C3 (R2C1) without going any further. In all honesty, I failed to come up with any
plausible explanation of such behavior, maybe it's just a quirk of Excel INDIRECT.
Creating indirect references from cell values and text
Similarly to how we created references from cell values, you can combine a text string and
a cell reference within your INDIRECT formula, tied together with the concatenation operator
(&).
In the following example, the formula: =INDIRECT("B"&C2) returns a value from cell B2 based
on the following logical chain:
The INDIRECT function concatenates the elements in the ref_text argument - text B and the
value in cell C2 -> the value in cell C2 is number 2, which makes a reference to cell B2 -> the
formula goes to cell B2 and returns its value, which is number 10.
Apples - B2:B6
Bananas - C2:C6
Lemons - D2:D6
To create a dynamic reference to any of the above named ranges, just enter its name in some
cell, say G1, and refer to that cell from an Indirect formula =INDIRECT(G1).
And now, you can take a step further and imbed this INDIRECT formula into other Excel
functions to calculate the sum and average of the values in a given named range, or find the
maximum / minimum value within the rage:
=SUM(INDIRECT(G1))
=AVERAGE(INDIRECT(G1))
=MAX(INDIRECT(G1))
=MIN(INDIRECT(G1))
Now that you've got the general idea of how to use the INDIRECT function in Excel, we can
experiment with more powerful formulas.
INDIRECT formula to dynamically refer to another worksheet
The usefulness of the Excel INDIRECT function is not limited to building "dynamic" cell
references. You can also utilize it to refer to cells in other worksheets "on the fly", and here's
how.
Suppose, you have some important data in Sheet 1, and you want to pull that data in Sheet 2.
The following screenshot demonstrates how an Excel Indirect formula can handle this task:
Let's break apart the formula you see in the screenshot and understand.
As you know, the usual way to reference another sheet in Excel is writing the sheet's name
followed by the exclamation mark and a cell / range reference, like SheetName!Range. Since a
sheet name often contains a space(s), you'd better enclose it (the name, not a space : ) in
single quotes to prevent an error, for example 'My Sheet!'$A$1.
And now, all you have to do is to enter the sheet name in one cell, the cell address in another,
concatenate them in a text string, and feed that string to the INDIRECT function. Remember
that in a text string, you have to enclose each element other than a cell address or number in
double quotes and link all elements together using the concatenation operator (&).
Given the above, we get the following pattern:
INDIRECT("'" & Sheet's name & "'!" & Cell to pull data from)
Going back to our example, you put the sheet's name in cell A1, and type the cell addresses in
column B, as demonstrated in the screenshot above. As the result, you get the following
formula:
INDIRECT("'" & $A$1 & "'!" & B1)
Also, please pay attention that if you are copying the formula into multiple cells, you have to lock
the reference to the sheet's name using the absolute cell references like $A$1.
Notes:
If either of the cells that contain the 2nd sheet's name and cell address (A1 and B1 in the
above formula) is empty, your Indirect formula will return an error. To prevent this, you can wrap
the INDIRECT function in the IF function:
IF(OR($A$1="",B1=""), "", INDIRECT("'" & $A$1 & "'!" & B1))
For the INDIRECT formula that refers to another sheet to work correctly, the referred
sheet should be open, otherwise the formula will return a #REF error. To avoid the error, you
can use the IFERROR function, which will display an empty string, whatever error occurs:
IFERROR(INDIRECT("'" & $A$1 & "'!" &B1), "")
Excel INDIRECT formula to refer to another workbook
The Indirect formula that refers to a different Excel workbook is based on the same approach as
areference to another spreadsheet. You just have to specify the workbook's name is addition to
the sheet name and cell address.
To make things easier, let's start with making a reference to another book in the usual way
(apostrophes are added in case your book and/or sheet names contain spaces):
'[Book_name.xlsx]Sheet_name'!Range
Assuming that the book name is in cell A2, the sheet name is in B2, and the cell address is in
C2, we get the following formula:
=INDIRECT("'[" & $A$2 & "]" & $B$2 & "'!" & C2)
Since you don't want the cells containing the book's and sheet's names to change when copying
the formula to other cells, you lock them by using the absolute cell references, $A$2 and $B$2,
respectively.
And now, you can easily write your own formula to dynamicity refer to another Excel workbook
by using the following pattern:
=INDIRECT("'[" & Book name & "]" & Sheet name & "'!" & Cell address)
Note. The workbook your formula refers to should always be open, otherwise the INDIRECT
function will throw a #REF error. As usual, the IFERROR function can help you avoid it:
=IFERROR(INDIRECT("'[" & A2 & "]" & $A$1 & "'!" & B1), "")
Using Excel INDIRECT function to lock a cell reference
Normally, Microsoft Excel changes cell references when you insert new or delete existing rows
or columns in a sheet. To prevent this from happening, you can use the INDIRECT function to
work with cell references that should remain intact in any case.
To illustrate the difference, please do the following:
1. Enter any value in any cell, say, number 20 in cell A1.
2. Refer to A1 from two other cells in different ways: =A1 and =INDIRECT("A1")
3. Insert a new row above row 1.
See what happens? The cell with the equal to logical operator still returns 20, because its
formula has been automatically changed to =A2. The cell with the INDIRECT formula now
returns 0, because the formula was not changed when a new row was inserted and it still refers
to cell A1, which is currently empty:
After this demonstration, you may be under the impression that the INDIRECT function is more
a nuisance than help. Okay, let's try it another way.
Suppose, you want to sum the values in cells A2:A5, and you can easily do this using the SUM
function:
=SUM(A2:A5)
However, you want the formula to remain unchanged, no matter how many rows are deleted or
inserted. The most obvious solution - the use of absolute references - won't help. To make sure,
enter the formula =SUM($A$2:$A$5) in some cell, insert a new row, say at row 3, and find the
formula converted to =SUM($A$2:$A$6).
Of course, such courtesy of Microsoft Excel will work fine in most cases. Nevertheless, there
may be scenarios when you don't want the formula to get changed automatically. The solution is
to use the INDIRECT function, like this:
=SUM(INDIRECT("A2:A5"))
Since Excel perceives "A1:A5" as a mere text string rather than a range reference, it won't make
any changes when you insert or delete a row(s).
Using INDIRECT with other Excel functions
Apart from SUM, INDIRECT is frequently used with other Excel functions such as ROW,
COLUMN, ADDRESS, VLOOKUP, SUMIF, to name a few.
Example 1. INDIRECT and ROW functions
Quite often, the ROW function is used in Excel to return an array of values. For example, you
can use the following array formula (remember it requires pressing Ctrl + Shift + Enter) to return
the average of the 3 smallest numbers in the range A1:A10:
=AVERAGE(SMALL(A1:A10,ROW(1:3)))
However, if you insert a new row in your worksheet, anywhere between rows 1 and 3, the range
in the ROW function will get changed to ROW(1:4) and the formula will return the average of the
4 smallest numbers instead of 3.
To prevent this from happening, nest INDIRECT in the ROW function and your array formula will
always remain correct, no matter how many rows are inserted or deleted:
=AVERAGE(SMALL(A1:A10,ROW(INDIRECT("1:3"))))
Here's a couple more examples of using INDIRECT and ROW in conjunction with the SUM and
SUMIF functions: How to sum the largest or smallest numbers in a range.
Example 2. INDIRECT and ADDRESS functions
You can use Excel INDIRECT together with the ADDRESS function to get a value in a certain
cell on the fly.
As you may remember, the ADDRESS function is used in Excel to get a cell address by the row
and column numbers. For example, the formula =ADDRESS(1,3) returns the string $C$1 since
C1 is the cell at the intersection of the 1st row and 3rd column.
To create an indirect cell reference, you simply embed the ADDRESS function into an
INDIRECT formula like this: =INDIRECT(ADDRESS(1,3))
Of course, this trivial formula only demonstrates the technique. For real-life examples of using
INDIRECT & ADDRESS functions in Excel, please see: How to convert rows to columns in
Excel.
And here are a few more formula examples that may prove useful:
VLOOKUP and INDIRECT - how to dynamically pull data from different sheets.
INDIRECT with INDEX / MATCH - how to bring a case-sensitive VLOOKUP formula to
perfection.
Excel INDIRECT and COUNTIF - how to use the COUNTIF function on a noncontiguous range or a selection of cells.
To make more complex 3-level menus or drop-downs with multi-word entries, you will need a bit
more complex INDIRECT formula with a nested SUBSTITUTE function.
For the detailed step-by-step guidance on how to use INDIRECT with Excel Data Validation,
please check out this tutorial: How to make a dependent drop down list in Excel.
Excel INDIRECT function - possible errors and issues
As demonstrated in the above examples, the INDIRECT function is quite helpful when dealing
with cell and range references. However, not all Excel users eagerly embrace it mostly because
extensive use of INDIRECT in Excel formulas results in lack of transparency. The INDIRECT
function is difficult to review since the cell it refers to is not the ultimate location of the value
used in the formula, which is pretty confusing indeed, especially when working with large
complex formulas.
In addition to the above said, like any other Excel function, INDIRECT may throw an error if you
misuse the function's arguments. Here's a list of most typical mistakes:
Excel INDIRECT #REF! error
Most often, the INDIRECT function returns a #REF! error in three cases:
1. ref_text is not a valid cell reference. If the ref_text parameter in your Indirect formula is not
a valid cell reference, the formula will result in the #REF! error value. To avoid possible issues,
please check the INDIRECT function's arguments.
2. Range limit is exceeded. If the ref_text argument of your Indirect formula refers to a range
of cells beyond the row limit of 1,048,576 or the column limit of 16,384, you will also get the
#REF error in Excel 2007, 2010 and Excel 2013. Earlier Excel versions ignore the exceeded
limit and do return some value, though often not the one you'd expect.
2. The referred sheet or workbook is closed. If your Indirect formula refers to another Excel
workbook or worksheet, that other workbook / spreadsheet must be open, otherwise INDIRECT
returns the #REF! error.
Excel INDIRECT #NAME? error
This is the most obvious case, implying that there is some error in the function's name, which
leads us to the next point : )
Using the INDIRECT function in non-English locales
You may be curious to know that the English name of the INDIRECT function has been
translated into 14 languages, including:
Danish - INDIREKTE
Finnish - EPSUORA
German - INDIREKT
Hungarian - INDIREKT
Italian - INDIRETTO
Norwegian - INDIREKTE
Polish - ADR.POR
Spanish - INDIRECTO
Swedish - INDIREKT
Turkish - DOLAYLI
If you are interested to get the full list, please check out this page.
A common problem with non-English localizations is not the INDIRECT function's name, but
rather different Regional Settings for the List Separator. In the standard Windows configuration
for North America and some other countries, the default List Separator is a comma. While in
European countries, the comma is reserved as the Decimal Symbol and the List Separator is
set to semicolon.
As a result, when copying a formula between two different Excel locales, you may get the error
message "We found a problem with this formula" because the List separator used in the
formula is different from what is set on your machine. If you run into this error when copying
some INDIRECT formula from this tutorial into your Excel, simply replace all commas (,) with
semicolons (;) to get it fixed.
To check which List Separator and Decimal Symbol are set on your machine, open the Control
Panel, and go to Region and Language > Additional Settings.
Hopefully, this tutorial has shed some light on using INDIRECT in Excel. Now that you know its
strengths and limitations, it's time to give it a shot and see how the INDIRECT function can
simplify your Excel tasks. Thank you for reading!
How to calculate compound interest in Excel - formula for daily, monthly, yearly
compounding
The tutorial explains the compound interest formula for Excel and provides examples of how to
calculate the future value of the investment at annual, monthly or daily compounding interest
rate. You will also find the detailed steps to create your own Excel compound interest calculator.
Compound interest is one of the basic building blocks in banking and one of the most powerful
financial forces around that determine the outcome of your investments.
Unless you are an accounting graduate, financial analyst or an experienced investor, it might be
a bit difficult to grasp the concept from specialized financial books and manuals. The aim of this
article is to make it easy : ) You will also learn how to use a compound interest formula in Excel
and create a universal compound interest calculator for your own worksheets.
o
o
o
o
It might be easier to start with simple interest that is calculated only on the principal amount.
For example, you put $10 into a bank account. How much will your deposit be worth in one year
at an annual interest rate of 7%? The answer is $10.7, and your earned interest is $0.70.
In case of compound interest, the principal in each time period is different. The bank won't
give the earned interest back to you, instead they add it to your principle investment. This
increased amount becomes the principal for the next time period (compounding period) and also
earns interest. In other words, you earn interest not only on the principal amount, but also on the
interest earned in each compounding period.
In our example, in addition to the principle amount of $10, the earned interest of $0.70 will also
earn interest next year. So, how much will your $10 deposit be worth after 2 years at the annual
interest rate of 7%? The answer is $11.45 and you can calculate it in several ways, as
demonstrated below.
As you remember, 1% is one part of a hundred, i.e. 0.01, so 7% is 0.07, and this is how
percentages are actually stored in Excel. Keeping this in mind, you can verify the result returned
by the formula by performing a simple calculation of 10*(1+0.07) or 10*1.07 and make sure that
your balance after 1 year will be $10.70 indeed.
And now, let's calculate the balance after 2 years. So, how much will your $10 deposit be worth
in two years' time at an annual interest rate of 7%? The answer is $11.45 and you can get it by
To calculate how much money you will find in your bank account at the end of 3 years, simply
copy the same formula to column E and you will get $12.25.
Those of you who have some experience with Excel formulas have probably figured out that
what the above formula actually does is multiplying the initial deposit of $10 by 1.07 three times:
=10*1.07*1.07*1.07=12.25043
Round it to two decimal places and you will get the same number as you see in cell E2 in the
screenshot above - $12.25. Naturally, you can directly calculate the balance after 3 years using
this formula:
=A2*1.07*1.07*1.07
Assuming that your Initial deposit is in cell B1 and Annual interest rate in cell B2, the following
formula works a treat: =B1 + B1 * $B$2
For the formula to work correctly, please mind the following details:
Fix the reference to the Annual Interest Rate cell (B2 in our case) by adding the $ sign, it
should be an absolute column and absolute row, like $B$2.
For Year 2 (B6) and all subsequent years, change the formula to:
Year 1 balance + Year 1 balance * Interest Rate
In this example, you'd enter the formula =B5 + B5 * $B$2 in cell B6 and then copy it down to
other rows, like demonstrated in the screenshot below.
To find out how much interest you actually earned with annual compound interest, enter the
formula =B5-B1 (Balance after 1 year - Initial deposit) in cell C5.
Then enter =B6-B5 (Balance after 2 years - Balance after 1 year) in cell C6 and drag the
formula down to other cells.
You should see the earned interest's growth like in the screenshot below that reveals the real
power of compound interest.
The above examples do a good job illustrating the idea of compound interest, don't they? But
none of the formulas is good enough to be called a universal compound interest formula for
Excel. Firstly, because they do not let you specify a compounding period, and secondly,
because you have to build an entire table rather than simply enter a certain duration and interest
rate.
Well, let's take a step forward and create a universal compound interest formula for Excel that
can calculate how much money you will earn with yearly, quarterly, monthly, weekly or daily
compounding.
General compound interest formula
When financial advisors analyze the impact of compound interest on an investment, they usually
consider three factors that determine the future value of the investment (FV):
First off, let's write down a list of components for your compound interest formula:
PV = $2,000
i = 8% per year, compounded monthly (0.08/12= 006666667)
n = 5 years x 12 months (5*12=60)
Input the above numbers in the formula, and you will get:
= $2,000 * (1 + 0.8/12)5x12
or
= $2,000 * 1.00666666760
or
= $2,000 * 1.489845708 = $2,979.69
Example 2: Daily compound interest formula
I hope the monthly compound interest example is well understood, and now you can use the
same approach for daily compounding. The initial investment, interest rate, duration and the
formula are exactly the same as in the above example, only the compounding period is different:
PV = $2,000
i = 8% per year, compounded daily (0.08/365 = 0.000219178)
n = 5 years x 365 days (5*365 =1825)
Supply the above numbers into the compound interest formula, and you will get the following
result:
=$2,000 * (1 + 0.000219178)1825 = $2,983.52
As you see, with daily compounding interest, the future value of the same investment is a bit
higher than with monthly compounding. This is because the 8% interest rate adds interest to the
principal amount each day rather than each month. As you can guess, the monthly
compounding result will be higher than annual compounding.
All this is good, but what you really want is an Excel formula for compound interest, right? Just
bear with me for a little longer, please. Now we are getting to the most interesting part - building
your own powerful and versatile compound interest calculator in Excel.
Universal compound interest formula in Excel (daily, weekly, monthly, yearly
compounding)
Usually, there is more than one way to do something in Excel and a compound interest formula
is not an exception :) Although Microsoft Excel provides no special function for calculating
compound interest, you can use other functions to create your own compound interest
calculator.
Let's start creating our Excel compound interest calculator with entering the basic factors that
determine the future value of an investment in an Excel worksheet:
All you need now is the compound interest formula to calculate the earned amount (Balance)
based on the input values. The best news is that you don't have to re-invent the wheel. We will
simply take the time-tested compound interest formula used by banking and other financial
institutions and slightly modify its expressions so that Excel can understand it.
Compound interest formula for Excel:
=Initial investment * (1 + Annual interest rate / Compounding periods per year) ^
(Years * Compounding periods per year)
When adjusted for the compound interest calculator shown in the screenshot above, the formula
takes the following shape:
The numbers look rather familiar? Yep, these are the same values and calculations that we've
performed with a monthly compound interest formula, and the result proves that we did
everything right!
If you want to know how much your investment will be worth at an 8% annual interest rate
compounded quarterly, simply enter 4 in cell B5:
To calculate the future value of your investment with semi-annual compounding, enter 2 as the
Compounding periods per year value. For weekly interest rates, enter 52, this is how many
weeks each year contains. If you are interested in daily compounding, enter 365, and so on.
As you see, we've created a truly universal compound interest calculator for Excel. Hopefully,
now you have no regrets that you invested a few precious minutes in figuring out the tricky
compound interest formula used by financial planners : )
And now, it's time to use this formula in your Excel spreadsheets, or you can download the
compound interest calculator we've just created.
rate - an interest rate per period, exactly as the argument's name suggests.
nper - the number of payment periods.
pmt - an additional payment that is made each period, represented as a negative
number. If the pmt argument is omitted, the pv parameter must be included.
pv (optional) - the present value of the investment (principle investment), which is also
anegative number. If the pv argument is omitted, it is assumed to be zero (0), in this case the
pmt parameter must be specified.
type (optional) - specifies when additional payments are due: 0 or omitted - at the end of
the period, and 1 - at the beginning of the period.
Let's use Excel FV formula with the same values as in monthly compound interest
examples and see whether we get the same result.
As you may remember, we deposited $2,000 for 5 years into a savings account at 8% annual
interest rate compounded monthly, with no additional payments. So, our Excel compound
interest formula goes as follows:
=FV(0.08/12, 5*12, ,-2000)
If you need some explanation of the parameters, here you go:
rate - 0.008/12 since you have the 8% annual interest rate compounded monthly.
nper - 5*12, i.e. 5 years * 12 months
pmt is left blank because our task does not involve additional payments to the principle
investment of $2,000.
pv is -2000 since the syntax of the FV function requires using a negative number in this
argument.
As demonstrated in the following screenshot, the FV formula returns the same result as the
compound interest calculator that we created in the previous example.
Naturally, nothing prevents you from replacing the values in the FV function with cell references,
and then your FV formula will double-check the result returned by our Excel compound interest
calculator.
For example, the screenshot below shows the future value of $4,000 investment after 15 years
at an annual interest rate of 7% compounded weekly.
To make your Excel compound interest calculator even more powerful, you can extend it with
theAdditional contributions option (additional payments) and modify the compound interest
formula accordingly:
=FV(B4/B5, B6*B5, -B8, -B3, B9)
Where:
B3 - principle investment
B4 - an annual interest rate
B5 - the number of compounding periods per year
B6 - the number of years to save
B8 - additional contributions (optional)
B9 - additional contributions type. Remember that you enter 1 if you deposit an
additional amount at the beginning of the compounding period, 0 or omitted if additional
payments are made at the end of the period.
If you are curious to try this advanced compound interest calculator for Excel to compute your
savings, feel free to download it.
Compound interest calculators online
If you prefer investing money rather than time in figuring out how to calculate compound interest
in Excel, online compound interest calculators may come in handy. You can find plenty of them
by entering something like "compound interest calculator" in your preferred search engine. In
the meantime, let me quickly present a couple of my favorite ones.
Compound interest calculator by Bankrate
The key benefits of Bankrate compound interest calculator is ease-of-use and visual
presentation of the results. This calculator lets you enter the savings inputs manually in boxes or
by moving a slider. As you do this, the estimated total is displayed on top and immediately
Clicking the View Report button generates a "Summary Report" as well as "Savings Balance"
that provides the detailed info on the amount of additional contributions, earned interest and
balance for each year.
Compound interest calculator by Money-Zine
The online calculator from Money-Zine is much simpler compared to Bankrate's one. It asks you
to specify only 3 values: the principle investment, interest rate and duration. As soon as you
supply these numbers and click the Calculate button, it will show you all types of compound
interest rate (daily, weekly, monthly, annual, etc.) as well as the future values with a
corresponding compounding.
you can see the summary info for that particular year.
This is how you calculate compound interest in Excel and outside it :) I hope at least one
compound interest formula discussed in this article has proved helpful to you. Anyway, I thank
you for reading and hope to see you on our blog next week!
Percentage basics
Excel percentage formula
Calculating percentage of total
Calculating percent change (percentage increase / decrease)
Calculate amount and total by percentage
Increase / decrease a number by percent
Percentage basics
The term "per cent" is derived from the Latin per centum, meaning "by the hundred". As you
probably remember from high school math class, a percentage is a fraction of 100 that is
calculated by dividing the numerator by the denominator and multiplying the result by 100.
The basic percentage formula is as follows:
(Part/Whole)*100 = Percentage
For example, if you had 20 apples and you gave 5 to your friends, how much did you give,
percentage wise? By performing a simple calculation =5/20*100 you get the answer - 25%.
This is how you normally calculate percentages in school and everyday life. Computing
percentage in Microsoft Excel is even easier since Excel performs some operations for you
automatically, in the background.
Regrettably, there is no universal Excel formula for percentage that would cover all possible
scenarios. If you ask someone "Which percent formula do I use to get the result I want?", most
likely, you will get an answer like "Well, that depends on what exactly result you want to
achieve."
So, let me show you a few simple formulas for calculating a percent in Excel such as a
percentage increase formula, a formula to get percentages of a total and more.
Enter the formula =C2/B2 in cell D2, and copy it down to as many rows as you need.
Click the Percent Style button (Home tab > Number group) to display the resulting
decimal fractions as percentages.
Remember to increase the number of decimal places if needed, as explained
in Percentage tips.
Done! : )
The same sequence of steps shall be performed when using any other percentage formula in
Excel.
In the following example, column D displays a rounded percent of delivered items, without any
decimal places showing.
In this case, you can use the SUMIF function to add up all numbers relating to a given product
first, and then divide that number by the total, like this:
=SUMIF(range, criteria, sum_range) / total
Given that column A contains all product names, column B lists corresponding quantities, cell E1
is the name of the product you are interested in, and the total is in cell B10, your real-life formula
may look similar to this:
=SUMIF(A2:A9 ,E1, B2:B9) / $B$10
Naturally, you can put the product name directly in the formula, like this:
=SUMIF(A2:A9, "cherries", B2:B9) / $B$10
If you want to find out what part of the total a few different products make, add up the results
returned by several SUMIF functions, and then divide that number by the total. For example, the
following formula calculates the percent of cherries and apples:
=(SUMIF(A2:A9, "cherries", B2:B9) + SUMIF(A2:A9, "apples", B2:B9)) / $B$10
For more information about the SUM function, please check out the following tutorials:
If you want to calculate percentage change compared to a certain cell, then you need to fix the
reference to that cell by using the absolute cell reference with the $ sign, e.g. $C$2.
For instance, here is the Excel percentage change formula that calculates the percent increase /
decrease for each month compared to January (C2):
=(C3-$C$2)/$C$2
When you drag the formula down to copy it to other cells, the absolute reference ($C$2) will
stay the same, while the relative reference (C3) will change to C4, C5 and so on.
Remember, when you type a number followed by the percent sign (%) in Excel, the number is
interpreted as a hundredth of its value. For example, 11% is actually stored as 0.11 and Excel
uses this underlying value in all formulas and calculations.
In other words, the formula =A2*11% is equivalent to =A2*0.11. Naturally, you are free to use
the decimal number corresponding to the percentage directly in a formula if this works better for
your worksheets.
Example 2. Calculating total by amount and percentage
For example, you friend offered you his old computer for $400, which is 30% off the original
price. You want to know what the original price was.
Since 30% is the discount, you deduct it from 100% first to know what percentage you actually
have to pay (100% - 30% = 70%). Now you need the formula to calculate the original price, i.e.
to find the number whose 70% equals 400.
The formula goes as follows:
Amount / Percentage = Total
Applied to real data, it may take any of the following shapes:
=A2/B2 or =A2/0.7 or =A2/70%
Naturally, you are free to replace 20% in the above formulas with the percentage you want.
3. Select the cell with the formula (C2 in our case) and copy it by pressing Ctrl + C.
4. Select the range of cells you want to change, right click the selection and then click Paste
Special
And here's the result - all the numbers in column B are increased by 20%:
In the same fashion, you can multiply or divide a column of numbers by a certain percentage.
Simply enter the desired percentage in an empty cell and follow the steps above.
This is how you calculate percentage in Excel. And even if working with percentages has never
been your favorite kind of math, by using these basic percentage formulas you can get Excel to
do the work for you. That's all for today, thank you for reading!
Description
AND
OR
XOR
Returns a logical
Exclusive Or of all
arguments.
Formula
Example
Formula Description
=AND(A2>=10,
B2<5)
=OR(A2>=10,
B2<5)
=XOR(A2>=10,
B2<5)
NOT
=NOT(A2>=10)
In additions to the four logical functions outlined above, Microsoft Excel provides 3 conditional
functions - IF, IFERROR and IFNA.
Excel logical functions - facts and figures
1. In arguments of the logical functions, you can use cell references, numeric and text values,
Boolean values, comparison operators, and other Excel functions. However, all arguments must
evaluate to the Boolean values of TRUE or FALSE, or in references or arrays containing logical
values.
2. If an argument of a logical function contains text values or empty cells, such values are
ignored.
3. If an argument of a logical function contains numbers, then zero evaluates to FALSE, and all
other numbers including negative numbers evaluate to TRUE. For example, if cells A1:A5
contain numbers, the formula =AND(A1:A5) will return TRUE if none of the cells contains 0,
FALSE otherwise.
4. A logical function returns the #VALUE! error if none of the arguments evaluate to logical
values.
5. A logical function returns the #NAME? error if you've misspell the function's name or
attempted to use the function in an earlier Excel version that does not support it. For example,
the XOR function can be used in Excel 2013 only.
6. In Excel 2013, 2010 and 2007, you can include up to 255 arguments in a logical function,
provided that the total length of the formula does not exceed 8,192 characters. In Excel 2003
and lower, you can supply up to 30 arguments and the total length of your formula shall not
exceed 1,024 characters.
Using the AND function in Excel
The AND function is the most popular member of the logic functions family. It comes in handy
when you have to test several conditions and make sure that all of them are met. Technically,
the AND function tests the conditions you specify and returns TRUE if all of the conditions
evaluate to TRUE, FALSE otherwise.
The syntax for the Excel AND function is as follows:
Description
=AND(A2="Bananas",
B2>C2)
=AND(B2>20, B2=C2)
=AND(A2="Bananas",
B2>=30, B2>C2)
For more IF / AND formula examples, please check out his tutorial: Excel IF function with
multiple AND conditions.
An Excel formula for the BETWEEN condition
If you need to create a between formula in Excel that picks all values between the given two
values, a common approach is to use the IF function with AND in the logical test.
For example, you have 3 values in columns A, B and C and you want to know if a value in
column A falls between B and C values. To make such a formula, all it takes is the IF function
with nested AND and a couple of comparison operators:
Formula to check if X is between Y and Z, inclusive:
=IF(AND(A2>=B2,A2<=C2),"Yes", "No")
Formula to check if X is between Y and Z, not inclusive:
=IF(AND(A2>B2, A2<C2),"Yes", "No")
As demonstrated in the screenshot above, the formula works perfectly for all data types numbers, dates and text values. When comparing text values, the formula checks them
character-by-character in the alphabetic order. For example, it states that Apples in not
between Apricot andBananas because the second "p" in Apples comes before "r" in Apricot.
Please see Using Excel comparison operators with text values for more details.
As you see, the IF /AND formula is simple, fast and almost universal. I say "almost" because it
does not cover one scenario. The above formula implies that a value in column B is smaller than
in column C, i.e. column B always contains the lower bound value and C - the upper bound
value. This is the reason why the formula returns "No" for row 6, where A6 has 12, B6 - 15 and
C6 - 3 as well as for row 8 where A8 is 24-Nov, B8 is 26-Dec and C8 is 21-Oct.
But what if you want your between formula to work correctly regardless of where the lowerbound and upper-bound values reside? In this case, use the Excel MEDIAN function that
returns the median of the given numbers (i.e. the number in the middle of a set of numbers).
So, if you replace AND in the logical test of the IF function with MEDIAN, the formula will go like:
=IF(A2=MEDIAN(A2:C2),"Yes","No")
As you see, the MEDIAN function works perfectly for numbers and dates, but returns the #NUM!
error for text values. Alas, no one is perfect : )
If you want a perfect Between formula that works for text values as well as for numbers and
dates, then you will have to construct a more complex logical text using the AND / OR functions,
like this:
=IF(OR(AND(A2>B2, A2<C2), AND(A2<B2, A2>C2)), "Yes", "No")
Description
=OR(A2="Bananas",
A2="Oranges")
=OR(B2>=40, C2>=20)
As well as Excel AND function, OR is widely used to expand the usefulness of other Excel
functions that perform logical tests, e.g. the IF function. Here are just a couple of examples:
IF function with nested OR
=IF(OR(B2>30, C2>20), "Good", "Bad")
The formula returns "Good" if a number in cell B3 is greater than 30 or the number in C2 is
greater than 20, "Bad" otherwise.
Excel AND / OR functions in one formula
Naturally, nothing prevents you from using both functions, AND & OR, in a single formula if your
business logic requires this. There can be infinite variations of such formulas that boil down to
the following basic patterns:
=AND(OR(Cond1, Cond2), Cond3)
The rule with the above OR formula highlights rows that contain an empty cell either in column
B or C, or in both.
For more information about conditional formatting formulas, please see the following articles:
In the simplest version of the XOR formula that contains just 2 logical statements, the Excel
XOR function returns TRUE if either argument evaluates to TRUE. If both arguments are TRUE
or neither is TRUE, XOR returns FALSE. This might be easier to understand from the formula
examples:
Formula
Result
Description
=XOR(1>0, 2<1)
TRUE
=XOR(1<0, 2<1)
FALSE
=XOR(1>0, 2>1)
FALSE
When more logical statements are added, the XOR function in Excel results in:
If you are not sure how the Excel XOR function can be applied to a real-life scenario, consider
the following example. Suppose you have a table of contestants and their results for the first 2
games. You want to know which of the payers shall play the 3rd game based on the following
conditions:
Contestants who won Game 1 and Game 2 advance to the next round automatically and
don't have to play Game 3.
Contestants who lost both first games are knocked out and don't play Game 3 either.
Contestants who won either Game 1 or Game 2 shall play Game 3 to determine who
goes into the next round and who doesn't.
A simple XOR formula works exactly as we want:
=XOR(B2="Won", C2="Won")
And if you nest this XOR function into the logical test of the IF formula, you will get even more
sensible results:
=IF(XOR(B2="Won", C2="Won"), "Yes", "No")
=NOT(C2="black")
As usual, in Microsoft Excel there is more than one way to do something, and you can achieve
the same result by using the Not equal to operator: =C2<>"black".
If you want to test several conditions in a single formula, you can use NOT in conjunctions with
the AND or OR function. For example, if you wanted to exclude black and white colors, the
formula would go like:
=NOT(OR(C2="black", C2="white"))
And if you'd rather not have a black coat, while a black jacket or a back fur coat may be
considered, you should use NOT in combination with the Excel AND function:
=NOT(AND(C2="black", B2="coat"))
Another common use of the NOT function in Excel is to reverse the behavior of some other
function. For instance, you can combine NOT and ISBLANK functions to create the
ISNOTBLANK formula that Microsoft Excel lacks.
As you know, the formula =ISBLANK(A2) returns TRUE of if the cell A2 is blank. The NOT
function can reverse this result to FALSE: =NOT(ISBLANK(A2))
And then, you can take a step further and create a nested IF statement with the NOT / ISBLANK
functions for a real-life task:
Translated into plain English, the formula tells Excel to do the following. If the cell C2 is not
empty, multiply the number in C2 by 0.15, which gives the 15% bonus to each salesman who
has made any extra sales. If C2 is blank, the text "No bonus :(" appears.
In essence, this is how you use the logical functions in Excel. Of course, these examples have
only scratched the surface of AND, OR, XOR and NOT capabilities. Knowing the basics, you
can now extend your knowledge by tackling your real tasks and writing smart elaborate formulas
for your worksheets.
Excel logical operators: equal to, not equal to, greater than, less than
Many tasks you perform in Excel involve comparing data in different cells. For this, Microsoft
Excel provides six logical operators, which are also called comparison operators. This tutorial
aims to help you understand the insight of Excel logical operators and write the most efficient
formulas for your data analysis.
o
o
o
Operator
Formula
Example
Description
Equal to
=A1=B1
Not equal to
<>
=A1<>B1
Greater than
>
=A1>B1
Less than
<
=A1<B1
=A1>=B1
=A1<=B1
Greater than or
equal to
Less than or
equal to
>=
<=
The screenshot below demonstrates the results returned by Equal to, Not equal to, Greater
thanand Less than logical operators:
It may seem that the above table covers it all and there's nothing more to talk about. But in fact,
each logical operator has its own specificities and knowing them can help you harness the real
power of Excel formulas.
Using "Equal to" logical operator in Excel
The Equal to logical operator (=) can be used to compare all data types - numbers, dates, text
values, Booleans, as well as the results returned by other Excel formulas. For example:
=A1=B1
Returns TRUE if the values in cells A1 and B1 are the same, FALSE
otherwise.
=A1="oranges"
=A1=TRUE
=A1=(B1/2)
To get the correct result, you must always wrap a date in the DATEVALUE function, like
this =A1=DATEVALUE("12/1/2014")
Note. The DATEVALUE function needs to be used with other logical operator as well, as
demonstrated in the examples that follow.
The same approach should be applied when you use Excel's equal to operator in the logical test
of the IF function. You can find more info as well as a few formula examples in this
tutorial: Using Excel IF function with dates.
Example 2. Using the "Equal to" operator with text values
Using Excel's Equal to operator with text values does not require any extra twists. The only thing
you should keep in mind is that the Equal to logical operator in Excel is case-insensitive,
meaning that case differences are ignored when comparing text values.
For example, if cell A1 contains the word "oranges" and cell B1 contains "Oranges", the formula
=A1=B1 will return TRUE.
If you want to compare text values taking in to account their case differences, you should use
the EXACT function instead of the Equal to operator. The syntax of the EXACT function is as
simple as:
EXACT(text1, text2)
Where text 1 and text2 are the values you want to compare. If the values are exactly the same,
including case, Excel returns TRUE; otherwise, it returns FALSE. You can also use the EXACT
function in IF formulas when you need a case-sensitive comparison of text values, as shown in
Note. If you want to compare the length of two text values, you can use the LEN function
instead, for example =LEN(A2)=LEN(B2) or =LEN(A2)>=LEN(B2).
Example 3. Comparing Boolean values and numbers
There is a widespread opinion that, in Microsoft Excel, the Boolean value of TRUE always
equates to 1 and FALSE to 0. However, this is only partially true, and the key word here is
"always" or more precisely "not always" : )
When writing an 'equal to' logical expression that compares a Boolean value and a number, you
need to specifically point out for Excel that a non-numeric Boolean value should be treated as a
number. You can do this by adding the double minus sign in front of a Boolean value or a cell
reference, e. g. =A2=--TRUE or =A2=--B2.
The 1st minus sign, which is technically called the unary operator, coerces TRUE/FALSE to -1/0,
respectively, and the second unary negates the values turning them into +1 and 0. This will
probably be easier to understand looking at the following screenshot:
Note. You should add the double unary operator before a Boolean when using other logical
operators such as not equal to, greater than or less than to correctly compare a numeric and
Boolean values.
When using logical operators in complex formulas, you might also need to add the double unary
before each logical expression that returns TRUE or FALSE as the result. Here's an example of
such a formula: SUMPRODUCT and SUMIFS in Excel.
Using "Not equal to" logical operator in Excel
You use Excel's Not equal to operator (<>) when you want to make sure that a cell's value is not
equal to a specified value. The use of the Not equal to operator is very similar to the use
of Equal tothat we discussed a moment ago.
The results returned by the Not equal to operator are analogous to the results produced by the
Excel NOT function that reverses the value of its argument. The following table provides a few
formula examples.
Not equal to operator
=A1<>B1
=A1<>"oranges"
=A1<>TRUE
=A1<>(B1/2)
NOT function
Description
=NOT(A1=B1)
Returns TRUE if
the values in
cells A1 and B1
are not the
same, FALSE
otherwise.
=NOT(A1="oranges")
Returns TRUE if
cell A1 contains
any value other
than "oranges",
FALSE if it
contains
"oranges" or
"ORANGES" or
"Oranges", etc.
=NOT(A1=TRUE)
Returns TRUE if
cell A1 contains
any value other
than TRUE,
FALSE
otherwise.
=NOT(A1=B1/2)
Returns TRUE if
a number in cell
A1 is not equal
to the quotient
of the division of
B1 by 2, FALSE
otherwise.
=A1<>DATEVALUE("12/1/2014")
=NOT(A1=DATEVALUE("12/1/2014"))
Returns TRUE if
A1 contains any
value other than
the date of 1Dec-2014,
regardless of
the date format,
FALSE
otherwise.
Greater than, Less than, Greater than or equal to, Less than or equal to
You use these logical operators in Excel to check how one number compares to another.
Microsoft Excel provides 4 comparison operates whose names are self-explanatory:
=A1>=(B1/2)
=A1<DATEVALUE("12/1/2014")
=A1<=SUM(B1:D1)
If the first letters are the same, then the 2nd letters are compared, if they happen to be identical
too, then Excel gets to the 3rd, 4th letters and so on. For example, if A1 contained "apples" and
B1 contained "agave", the formula =A1>B1 would return TRUE because "p" is greater than "g".
At first sight, the use of comparison operators with text values seems to have very little practical
sense, but you never know what you might need in the future, so probably this knowledge will
prove helpful to someone.
Common uses of logical operators in Excel
In real work, Excel logical operators are rarely used on their own. Agree, the Boolean values
TRUE and FALSE they return, though very true (excuse the pun), are not very meaningful. To
get more sensible results, you can use logical operators as part of Excel functions or conditional
formatting rules, as demonstrated in the below examples.
1. Using logical operators in arguments of Excel functions
When it comes to logical operators, Excel is very permissive and allows using them in
parameters of many functions. One of the most common uses is found in Excel IF
function where the comparison operators can help to construct a logical test, and the IF formula
will return an appropriate result depending on whether the test evaluates to TRUE or FALSE.
For example:
=IF(A1>=B1, "OK", "Not OK")
This simple IF formula returns OK if a value in cell A1 is greater than or equal to a value in cell
B1, "Not OK" otherwise.
And here's another example:
=IF(A1<>B1, SUM(A1:C1), "")
The formula compares the values in cells A1 and B1, and if A1 is not equal to B1, the sum of
values in cells A1:C1 is returned, an empty string otherwise.
Excel logical operators are also widely used in special IF functions such as SUMIF, COUNTIF,
AVERAGEIF and their plural counterparts that return a result based on a certain condition or
multiple conditions.
You can find a wealth of formula examples in the following tutorials:
I guess the IF formula is easier to interpret, right? It tells Excel to multiply a value in cell B2 by
10 if B2 is greater than C2, otherwise the value in B1 is multiplied by 5.
Now, let's analyze what the 2nd formula with the greater than and less than or equal to logical
operators does. It helps to know that in mathematical calculations Excel does equate the
Boolean value TRUE to 1, and FALSE to 0. Keeping this in mind, let's see what each of the
logical expressions actually returns.
If a value in cell B2 is greater than a value in C2, then the expression B2>C2 is TRUE, and
consequently equal to 1. On the other hand, B2<=C2 is FALSE and equal to 0. So, given that
B2>C2, our formula undergoes the following transformation:
Since any number multiplied by zero gives zero, we can cast away the second part of the
formula after the plus sign. And because any number multiplied by 1 is that number, our
complex formula turns into a simple =B2*10 that returns the product of multiplying B2 by 10,
which is exactly what the above IF formula does : )
Obviously, if a value in cell B2 is less than in C2, then the expression B2>C2 evaluates to
FALSE (0) and B2<=C2 to TRUE (1), meaning that the reverse of the described above will
occur.
3. Logical operators in Excel conditional formatting
Another common use of logical operators is found in Excel Conditional Formatting that lets you
quickly highlight the most important information in a spreadsheet.
For example, the following simple rules highlight selected cells or entire rows in your worksheet
depending on a value in column A:
Less than (orange): =A1<5
Greater than (green): =A1>20
For the detailed-step-by-step instructions and rule examples, please see the following articles:
Excel IF function: nested IF formulas with multiple conditions, IFERROR, IFNA and
more
In Part 1 of our Excel IF function tutorial, we started to learn the nuts and bolts of the Excel IF
function. As you remember, we discussed a few IF formulas for numbers, dates and text values
as well as how to use the IF function with blank and non-blank cells.
However, for powerful data analysis, you may often need to evaluate multiple conditions at a
time, meaning you have to construct more sophisticated logical tests using multiple IF functions
in one formula. The formula examples that follow below will show you how to do this correctly.
You will also learn how to use Excel IF in array formulas and learn the basics of the IFEFFOR
and IFNA functions.
AND function. If your logical test contains the AND function, Microsoft Excel returns
TRUE if all the conditions are met; otherwise it returns FALSE.
OR function. In case you use the OR function in the logical test, Excel returns TRUE
if any of the conditions is met; FALSE otherwise.
To illustrate the point better, let's have a look at a few IF examples with multiple conditions.
Example 1. Using IF & AND function in Excel
Suppose, you have a table with the results of two exam scores. The first score, stored in column
C, must be equal to or greater than 20. The second score, listed in column D, must be equal to
or exceed 30. Only when both of the above conditions are met, a student passes the final exam.
The easiest way to make a proper formula is to write down the condition first, and then
incorporate it in the logical_test argument of your IF function:
Condition: AND(B2>=20, C2>=30)
IF/AND formula: =IF((AND(C2>=20, D2>=30)), "Pass", "Fail")
Easy, isn't it? The formula tells Excel to return "Pass" if a value in column C >=20 AND a value
in column D >=30. Otherwise, the formula returns "Fail". The screenshot below proves that our
Note. Microsoft Excel checks all conditions in the AND function, even if one of the already
tested conditions evaluates to FALSE. Such behavior is a bit unusual since in most of
programming languages, subsequent conditions are not tested if any of the previous tests has
returned FALSE.
In practice, a seemingly correct IF / AND formula may result in an error because of this
specificity. For example, the formula =IF(AND(A2<>0,(1/A2)>0.5),"Good", "Bad") will return
"Divide by Zero Error" (#DIV/0!) if cell A2 is equal to 0. The avoid this, you should use a nested
IF function: =IF(A2<>0, IF((1/A2)>0.5, "Good", "Bad"), "Bad")
Example 2. Using IF with OR function in Excel
You use the combination of IF & OR functions in a similar way. The difference from the IF / AND
formula discussed above is that Excel returns TRUE if at least one of the specified conditions is
met.
So, if we modify the above formula in the following way:
=IF((OR(C2>=20, D2>=30)), "Pass", "Fail")
Column E will have the "Pass" mark if either the first score is equal to or greater than 20 OR the
second score is equal to or greater than 30.
As you see in the screenshot below, our students have a better chance to pass the final exam
with such conditions (Scott being particularly unlucky failing by just 1 point : )
Naturally, you are not limited to using only two AND/OR functions in your Excel IF formulas. You
can use as many logical functions as your business logic requires, provided that:
In Excel 2013, 2010 and 2007, your formula includes no more than 255 arguments, and
the total length of the formula does not exceed 8,192 characters.
In Excel 2003 and lower, you can use up to 30 arguments and the total length of your
formula shall not exceed 1,024 characters.
Example 3. Using IF with AND & OR functions
In case you have to evaluate your data based on several sets of multiple conditions, you will
have to employ both AND & OR functions at a time.
In the above table, suppose you have the following criteria to evaluate the students' success:
And now, let's write a nested IF function based on the above conditions. It's considered a good
practice to start with the most important condition and make your functions as simple as
possible. Our Excel nested IF formula is as follows:
=IF(E2>=60, "Good", IF(E2>40, "Satisfactory", "Poor "))
As you see, just one nested IF function is sufficient in this case. Naturally, you can nest more IF
functions if you want to. For example:
=IF(E2>=70, "Excellent", IF(E2>=60, "Good", IF(E2>40, "Satisfactory", "Poor ")))
The above formula adds one more conditions - the total score of 70 points and more is qualified
as "Excellent".
I've heard some people say that multiple Excel IF functions are driving them crazy : ) Probably, it
will help if you try to look at our nested IF formula in this way:
What the formula actually tells Excel to do is to test the condition of the first IF function and
return the value supplied in the value_if_true argument if the condition is met. If the condition
of the 1st IF function is not met, then test the 2nd IF, and so on.
=IF(check if E2>=70, if true - return "Excellent", or else
IF(check if E2>=60, if true - return "Good", or else
IF(check if E2>40, if true - return "Satisfactory", if false
- return " Poor ")))
Excel nested IF functions - things to remember!
1. In modern versions of Excel 2013, 2010 and 2010, you can use up to 64 nested IF functions.
In older versions of Excel 2003 and lower, up to 7 nested IF functions can be used.
2. If your IF formula includes more than 5 nested IF functions, you may want to optimize it by
using the alternatives described below.
Alternatives to multiple IF functions in Excel
To get around the limit of seven nested IF functions in older Excel versions and to make your IF
formula more compact and fast, consider using the following approaches instead of multiple IF
statements.
1. To test many conditions, use the LOOKUP, VLOOKUP, INDEX/MATCH or CHOOSE
functions.
2. Use IF with logical functions OR / AND, as demonstrated in the above examples.
3. Use the CONCATENATE function or the concatenate operator (&).
As well as other Excel functions, CONCATENATE can include as many as 30 parameters in
older Excel versions and up to 255 arguments in modern versions, which equates to testing 255
different conditions.
For example, if you want to return different values depending on the content of cell B1, you can
use the following formulas:
Nested IF functions:
=IF(C1="a", "Excellent", IF(C1="b", "Good", IF(C1="c", "Poor", "")))
CONCATENATE function:
=CONCATENATE(IF(C1="a", "Excellent", ""), IF(C1="b", "Good", ""), IF(C1="c", "Poor ",
""))
Concatenate operator:
=IF(C1="A", "Excellent", "") & IF(C1="B", " Good", "") & IF(C1="C", "Poor", "")
As you see, the use of CONCATENATE does not make the formula shorter, but it does make it
easier-to-understand compared to nested IF functions.
4. For powerful Excel users, the best alternative to using multiple nested IF functions might be
creating a custom worksheet function using VBA.
Using Excel IF in array formulas
Like other Excel functions, IF can be used in array formulas. You may need such a formula if
you want to evaluate every element of the array when the IF statement is carried out.
For example, the following array SUM/IF formula demonstrates how you can sum cells in the
specified range based on a certain condition rather than add up the actual values:
=SUM(IF(B1:B5<=1,1,2))
The formula assigns a certain number of "points" to each value in column B - if a value is equal
to or less than 1, it equates to 1 point; and 2 points are assigned to each value greater than 1.
And then, the SUM function adds up the resulting 1's and 2's, as shown in the screenshot
below.
Note. Since this is an array formula, remember to press Ctrl + Shift + Enter to enter it correctly.
Using IF function together with other Excel functions
Earlier in this tutorial, we've discussed a few IF formula examples demonstrating how to use the
Excel IF function with logical functions AND and OR. Now, let's see what other Excel functions
can be used with IF and what benefits this gives to you.
Example 1. Using IF with SUM, AVERAGE, MIN and MAX functions
When discussing nested IF functions, we wrote the formula that returns different ranking
(Excellent, Good, Satisfactory or Poor) based on the total score of each student. As you
remember, we added a new column with the formula that calculates the total of scores in
columns C and D.
But what if your table has a predefined structure that does not allow any modifications? In this
case, instead of adding a helper column, you could add values directly in your If formula, like
this:
=IF((C2+D2)>=60, "Good", IF((C2+D2)>=>40, "Satisfactory", "Poor "))
Okay, but what if your table contains a lot of individual scores, say 5 different columns or more?
Summing so many figures directly in the IF formula would make it enormously big. An
alternative is embedding the SUM function in the IF's logical test, like this:
In a similar fashion, you can use other Excel functions in the logical test of your IF formulas:
IF and AVERAGE:
=IF(AVERAGE(C2:F2)>=30,"Good",IF(AVERAGE(C2:F2)>=25,"Satisfactory","Poor "))
The formulas retunes "Good" if the average score in columns C:F is equal to or greater than 30,
"Satisfactory" if the average score is between 29 and 25 inclusive, and "Poor" if less than 25.
IF and MAX/MIN:
To find the highest and lowest scores, you can use the MAX and MIN functions, respectively.
Assuming that column F is the total score column, the below formulas work a treat:
MAX: =IF(F2=MAX($F$2:$F$10), "Best result", "")
MIN: =IF(F2=MIN($F$2:$F$10), "Worst result", "")
If you'd rather have both the Min and Max results in the same column, you can nest one of the
above functions in the other, for example:
In a similar manner, you can use the IF function with your custom worksheet functions. For
example, you can use it with the GetCellColor / GetCellFontColor functions to return different
results based on a cell color.
In addition, Excel provides a number of special IF functions to analyze and calculate data based
on different conditions.
For example, to count the occurrences of a text or numeric value based on a single or multiple
conditions, you can use COUNTIF and COUNTIFS, respectively. To find out a sum of values
based on the specified condition(s), use the SUMIF or SUMIFS functions. To calculate the
average according to certain criteria, use AVERAGEIF or AVERAGEIFS.
For the detailed step-by-step formula examples, check out the following tutorials:
Note. Please pay attention that the above formula displays "Number" for numeric values and
dates. This is because Microsoft Excel stores dates as numbers, starting from January 1, 1900,
which equates to 1.
Example 3. Using the result returned by IF in another Excel function
Sometimes, you can achieve the desired result by embedding the IF statement in some other
Excel function, rather than using another function in a logical test.
Here's another way how you can use the CONCATINATE and IF functions together:
=CONCATENATE("You performed ", IF(C1>5,"fantastic!", "good"))
I believe you hardly need any explanation of what the formula does, especially looking at the
screenshot below:
As you see in the screenshot above, column D displays the quotient of the division of a value in
column B by a value in column C. You can also see two error messages in cells D2 and D5
because everyone knows that you cannot divide a number by zero.
In some cases, you'd better use the IF function to prevent an error then ISERROR or ISNA to
catch an error. Firstly, it's a faster way (in terms of CPU) and secondly it is a good programming
practice. For example, the following IF formula produces the same result as the IFERROR
function demonstrated above:
=IF(C2=0, "Sorry, an error has occurred", B2/C2)
But of course, there are cases when you cannot pre-test all function parameters, especially in
very complex formulas, and foresee all possible errors. In such cases, the ISERROR() and
IFNA() functions come in really handy. You can find a few advanced examples of using
IFERROR in Excel in these articles:
Using IF function in Excel: formulas for numbers, text, dates, blank cells
The IF function is one of the most popular and useful functions in Excel. You use the IF function
to ask Excel to test a condition and to return one value if the condition is met, and another value
if the condition is not met.
In this tutorial, we are going to learn the syntax and common usages of Excel IF function, and
then will have a closer look at formula examples that will hopefully prove helpful both to
beginners and experienced Excel users.
o
o
o
o
2. If value_if_false is omitted.
If you don't care what happens if the specified condition is not met, you can omit the 3rd
parameter in your Excel IF formulas, which will result in the following.
If the logical test evaluates to FALSE and the value_if_false parameter is omitted (there is just
a closing bracket after the value_if_true argument), the IF function returns the logical value
FALSE. It's a bit unexpected, isn't it? Here is an example of such a formula: =IF(B1>10,
"Good")
If you put a comma after the value_if_true argument, your IF function will returns 0, which
doesn't make much sense either: =IF(B1>10, "Good",)
And again, the most reasonable approach is to put "" in the third argument, in this case you will
have empty cells when the condition is not met: =IF(B1>10, "Good", "")
=IF(B1>10, TRUE)
Note. If you want your IF formula to return TRUE and FALSE as the logical values (Boolean)
that other Excel formulas can recognize, make sure you don't enclose them in double quotes. A
visual indication of a Boolean is middle align in a cell, as you see in the screenshot above.
If you want to "TRUE" and "FALSE" to be usual text values, enclose them in "double quotes". In
this case, the returned values will be aligned left and formatted as General. No Excel formula
will recognize such "TRUE" and "FALSE" text as logical values.
4. Get IF to perform a math operation and return a result
Instead of returning certain values, you can make your IF formula to test the specified condition,
perform a corresponding math operation and return a value based on the result. You do this by
using arithmetic operators or other Excel functions in the value_if_true and
/or value_if_false arguments. Here are just a couple of formula examples:
Example 1: =IF(A1>B1, C3*10, C3*5)
The formula compares the values in cells A1 and B1, and if A1 is greater than B1, it multiplies
the value in cell C3 by 10, by 5 otherwise.
Example 2: =IF(A1<>B1, SUM(A1:D1), "")
The formula compares the values in cells A1 and B1, and if A1 is not equal to B1, the formula
returns the sum of values in cells A1:D1, an empty string otherwise.
Using the IF function in Excel - formula examples
Now that you are familiar with the Excel IF function's syntax, let's look at some formula
examples and learn how to use IF as a worksheet function in Excel.
Operator
Formula Example
Description
Greater than
>
=IF(A2>5, "OK",)
Less than
<
=IF(A2<5, "OK",
"")
Equal to
=IF(A2=5, "OK",
"Wrong number")
Not equal to
<>
=IF(A2<>5,
"Wrong number",
"OK")
Greater than
or equal to
>=
=IF(A2>=5, "OK",
"Poor")
Less than or
equal to
<=
=IF(A2<=5, "OK",
"")
The screenshot below demonstrates the IF formula with the "Greater than or equal to" logical
operator in action:
Another way to achieve exactly the same result is to use the "not equal to" operator and swap
the value_if_true and value_if_false arguments:
=IF(C2<>"delivered", "Yes", "No")
Example 2. Case-sensitive IF formula for text values
If you want a case-sensitive logical test, use the IF function in combination with EXACT that
compares two text strings and returns TRUE if the strings are exactly the same, otherwise it
returns FALSE. The EXACT functions is case-sensitive, though it ignores formatting differences.
Naturally, you can also use a cell reference rather than a text value in the 2nd argument of the
EXACT function, if you want to.
Note. When using text values as parameters for your IF formulas, remember to always enclose
them in "double quotes".
Example 3. IF formula for text values with partial match
If you want to base your condition on a partial match rather than exact match, an immediate
solution that comes to mind is using wildcard characters (* or ?) in the logical_test argument.
However, this simple and obvious approach won't work. Many Excel functions accept wildcards,
but regrettably IF is not one of them.
A solution is to use IF in combination with ISNUMBER and SEARCH (case-insensitive) or FIND
(case-sensitive) functions.
For example, if No action is required both for "Delivered" and "Out for delivery" items, the
following formula will work a treat:
We've used the SEARCH function in the above formula since a case-insensitive match suits
better for our data. If you want a case-sensitive match, simply replace SEARCH with FIND in
this way:
=IF(ISNUMBER(FIND("text", where to search)), value_if_true, value_if_false)
Excel IF formula examples for dates
At first sight, it may seem that IF formulas for dates are identical to IF functions for numeric and
text values that we've just discussed. Regrettably, it is not so.
Unlike many other Excel functions, IF cannot recognize dates and interprets them as mere text
strings, which is why you cannot express your logical test simply as >"11/19/2014" or
>11/19/2014. Neither of the above arguments is correct, alas.
Example 1. IF formulas for dates with DATEVALUE function
To make the Excel IF function to recognize a date in your logical test as a date, you have to
wrap it in the DATEVALUE function, like this DATEVALUE("11/19/2014"). The complete IF
formula may take the following shape:
=IF(C2<DATEVALUE("11/19/2014"), "Completed", "Coming soon")
As illustrated in the screenshot below, this IF formula evaluates the dates in column C and
returns "Completed" if a game was played before Nov-11. Otherwise, the formula returns
"Coming soon".
If you want to have both indications in one column, you will need to use a nested IF function like
this:
=IF(A2-TODAY()>30, "Future date", IF(TODAY()-A2>30, "Past date", ""))
Logical test
=""
Blank
cells
ISBLANK()
Description
Formula Example
Evaluates to TRUE if a
specified cell is visually
empty, including cells
withzero length strings.
=IF(A1="", 0, 1)
Otherwise, evaluates to
FALSE.
Evaluates to TRUE is a
specified cell
containsabsolutely
nothing - no formula, no
empty string returned by
some other formula.
=IF(ISBLANK(A1), 0, 1)
Otherwise, evaluates to
FALSE.
Evaluates to TRUE if a
specified cell contains
some data. Otherwise,
evaluates to FALSE.
=IF(A1<>"", 1, 0)
Evaluates to TRUE if a
specified cell is not empty.
Otherwise, evaluates to
FALSE.
=IF(ISBLANK(A1)=FALSE, 0, 1)
Returns 1 if A1 is non-blank;
otherwise returns 0.
<>""
Nonblank
cells
ISBLANK()=FALSE
Hopefully, the above examples have helped you understand the general logic of the IF function.
In practice, however, you would often want a single IF formula to check multiple conditions, and
our next article will show you how to tackle this task. In addition, we will also explore nested IF
functions, array IF formulas, IFEFFOR and IFNA functions and more. Please stay tuned and
thank you for reading!
In this Excel pivot table tutorial you fill learn what a PivotTable is, find a number of pivot table
examples that will help you to get started quickly and see how to create and use pivot tables in
Excel 2013, 2010 and 2007.
If you are working with large data sets in Excel, pivot tables come in really handy as a quick way
to make an interactive summary from many records. Among other features, an Excel pivot table
can automatically sort and filter different subsets of data, count totals, calculate average as well
as create cross tabulations.
Another benefit of using pivot tables is that you can set up and change the structure of your
summary table simply by dragging and dropping the source table's columns. This rotation or
pivoting gave the feature its name.
For example, you may have hundreds of entries in your Excel worksheet with sales figures of
local resellers:
One possible way to sum this long list of numbers by one or several conditions is to use Excel
formulas as demonstrated in SUMIF and SUMIFS tutorials. However, if you want to compare
several facts about each figure, using a pivot table is a far more efficient way. In just a few
mouse clicks, you can get a resilient and easily customizable summary table that totals the
The screenshots above demonstrate just a few of many possible pivot table layouts. And the
steps below show how you can quickly create your own pivot table in Excel 2013, 2010 and
2007.
How to make a pivot table in Excel: quick start
Many people think that creating an Excel pivot table is burdensome and time-consuming. But
this is not true! Microsoft has been refining the PivotTable technology for many years, and in the
modern versions of Excel, pivot tables are user-friendly are incredibly fast. In fact, you can build
your own summary table in just a couple of minutes. And here's how:
1. Organize your source data in an Excel Table
Before creating a pivot table, organize your data into rows and columns, and then convert your
data range in to an Excel Table. To do this, select all of the data, go to the Inset tab and
click Table.
Using an Excel Table for the source data gives you a very nice benefit - your data range
becomes "dynamic". In this context, a dynamic range means that your table will automatically
expand and shrink as you add or remove entries, so won't have to worry that your pivot table is
missing the latest data.
Useful tips:
Add unique, meaningful headings to your columns, they will turn into the pivot table's
field names later.
Make sure your source table contains no blank rows or columns, and no subtotals.
To make it easier to maintain your pivot table, you can name your source table by
switching to the Design tab and typing the name in the Table Name box the upper right corner
of your worksheet.
2. Create a pivot table
Select any cell in the source data table (if you are building a pivot table based on a range of
cells, select all cells with the data that you want to include), and then go to the Insert tab
> Tables group > PivotTable.
This will open the Create PivotTable window. Make sure the correct table or range of cells is
highlighted in the Table/Range field. Then choose the target location for your Excel pivot table:
Selecting New Worksheet will place a pivot table in a new worksheet starting at cell A1.
Selecting Existing Worksheet will place your pivot table at the specified location in an
existing worksheet. In the Location box, click the range selection icon
to choose the first cell
where you want to position your pivot table.
Clicking OK creates a blank pivot table in the target location, which will look similar to this:
Useful tips:
In most cases, it's convenient to have a pivot table in a separate worksheet, this is
especially recommended for beginners.
If you are creating a pivot table from the data in another worksheet or workbook,
include the workbook and worksheet names using the following syntax
[workbook_name]sheet_name!range, for example, [Book1.xlsx]Sheet1!$A$1:$E$20.
Alternatively, you can click the range selection icon
and select a table or range of cells in
another workbook using the mouse.
It might be useful to create a pivot table and pivot chart at the same time. To do this, in
Excel 2013, go to the Insert tab > Charts group, click the arrow below the PivotChart button, and
then click PivotChart & PivotTable. In Excel 2010 and 2007, click the arrow belowPivotTable,
and then click PivotChart.
3. Arranging the layout of your pivot table report
The Excel Pivot Table user interface is very intuitive and easy-to-use. The area where you work
with the fields of your pivot tables is called PivotTable Field List. Itis located in the right-hand
part of the worksheet and divided into the header and body sections:
The Field Section contains the names of the fields that you can add to your pivot table.
The filed names correspond to the column names of your source table.
The Layout Section contains the Report Filter area, Column Labels, Row Labels area,
and theValues area. Here you can arrange and re-arrange the fields of your pivot table.
The changes that you make in the PivotTable Field List are immediately reflected to your pivot
table.
How to add a field to the pivot table
To add a field to the Layout section, select the check box next to the field name in
the Fieldsection.
By default, Microsoft Excel adds the fields to the Layout section in the following way:
Uncheck the box nest to the field's name in the Field section of the PivotTable pane.
Right-click on the field in your pivot table, and then click "Remove Field_Name".
2. Right-click the field name in the Field section, and then select the area where you want to
add it:
3. Click on the filed in the Layout section to select it. This will also display the options available
for that particular field.
theCalculations group.
Tip. The Show Values As feature may prove especially useful if you add the same field to a
pivot table more than once and show, for example, total sales and sales as a percent of total at
the same time. See an example of such a table.
This is how you create pivot tables in Excel. And now it's time for you to experiment with your
pivot table fields a bit to choose the layout best suited for your data set.
Working with PivotTable Field List
The pivot table pane, which is formally called PivotTable Field List, is the main tool that you
use to arrange your summary table exactly the way you want. To make your work with the fields
more comfortable, you may want to customize the pane to your liking.
Changing the Field List view
If you want to change how the sections are displayed in the Field List, click the Tools button,
and choose your preferred layout.
You can also resize the pane horizontally by dragging the bar (splitter) that separates the
PivotTable pane from the worksheet.
Closing and opening the PivotTable pane
Closing thePivotTableField List is as easy as clicking the Close button (X) in the top right corner
of the pane.Making it to show up again is not so obvious :)
To display the Field List again, right-click anywhere in the pivot table, and then select Show
Field List from the context menu.
You can also click the Field List button on the Ribbon, which resides on the Analyze /
Options tab, in the Show group.
4. If you are happy with the preview, click the OK button, and get a pivot table added to a new
worksheet.
As you see in the screenshot above, Excel 2013 was able to suggest just a couple of basic
layouts for my source data, which are far inferior to the pivot tables we created manually a
moment ago. Of course, this is only my opinion and I am biased, you know : )
Overall, using the Recommended PivotTable in Excel 2013 is a quick way to get started,
especially when you have a lot of data and are not sure where to start.
How to use pivot table in Excel
Now that you know the pivot table basics, you can navigate to the Analyze and Design tabs of
thePivotTable Tools in Excel 2013 (Options and Design tabs in Excel 2010 and 2007) to
explore the groups and options provided there. These tabs become available as soon as you
click anywhere within your pivot table.
You can also access options and features that are available for a specific pivot table element by
right-clicking that element.
How to design and improve an Excel pivot table
Once you have created a pivot table based on your source data, you may want to refine it
further to make powerful data analysis.
To improve the pivot table's design, head over to the Design tab where you will find plenty of
pre-defined pivot table styles. To create your own style, click the More button in the PivotTable
Stylesgallery, and then click "New PivotTable Style".
To customize the layout of a certain field, click on that field, then click the Field Settings button
on the Analyze tab in Excel 2013 (Options tab in Excel 2010 and 2007). Alternatively, you can
right click the field and choose Field Settings from the context menu.
The screenshot below demonstrate a new design and layout for our pivot table in Excel 2013.
This will cause your Excel pivot table to display the actual field names, as you see in the pivot
table on the right, which makes much more sense.
Another solution is to go to the Analyze (Options) tab, click the Options button, switch to
the Displaytab and uncheck the "Display Field Captions and Filter Dropdowns" box. However,
this will remove all field captions as well as filter dropdowns in your pivot table.
How to refresh a pivot table in Excel
Although a pivot table report is connected to your source data, you might be surprised to know
that Excel does not refresh it automatically. You can get any data updates by performing a
refresh operation manually, or have it refresh automatically when you open the workbook.
Refresh the pivot table data manually
1. Click anywhere in your pivot table.
2. On the Analyze tab in Excel 2013 (Options tab in earlier versions), in the Data group, click
theRefresh button, or press ALT+F5.
Alternatively, you can right-click the pivot table, and choose Refresh from the context menu.
To refresh all pivot tables in your Excel workbook, click the Refresh button arrow, and then
clickRefresh All.
Note. If the format of your pivot table gets changed after refreshing, make sure the "Autofit
column width on update" and "Preserve cell formatting on update" options are selected. To
check this, click the Analyze (Options) tab > PivotTable group > Options button. In
the PivotTable Optionsdialog box, switch to the Layout & Format tab and you will find these
check boxes there.
After starting a refresh, you can review the status or cancel it if you've changed your mind.
Just click on the Refresh button arrow, and then click either Refresh Status or Cancel Refresh.
Refreshing a pivot table automatically when opening the workbook
1. On the Analyze / Options tab, in the PivotTable group, click Options > Options.
2. In the PivotTable Options dialog box, go to the Data tab, and select the Refresh data when
opening the file check box.
If your pivot table resides in a separate worksheet, simply delete that sheet.
If your pivot table is located along with some other data on a sheet, select the entire
pivot table using the mouse and press the Delete key.
Click anywhere in the pivot table that you want to delete, go to the Analyze tab in Excel
2013 (Options tab in Excel 2010 and earlier) > Actions group, click the little arrow below
the Selectbutton, choose Entire PivotTable, and then press Delete.
Note. If any PivotTable chart is associated with your pivot table, deleting the pivot table will turn
it into a standard chart can no longer be pivoted or updated.
Pivot table example 3: One field is displayed twice - as total and % of total
No Filter
Rows: Product, Reseller
Values: SUM of Sales, % of Sales
This pivot table shows total sales and sales as a percent of total at the same time.
Hopefully, this pivot table tutorial has been a good starting point for you. If you want to learn
advanced features and capabilities of Excel pivot tables, check out the links below. And thank
you for reading!
How to use Excel SUMIFS and SUMIF with multiple criteria - formula examples
This tutorial explains the difference between the SUMIF and SUMIFS functions in terms of their
syntax and usage, and provides a number of formula examples to sum values with multiple
AND / OR criteria in Excel 2013, 2010, 2007, 2003 and lower.
As everyone knows, Microsoft Excel provides an array of functions to perform various
calculations with data. A few articles ago, we explored COUNTIF and COUNTIFS, which are
designed for counting cells based on a single condition and several conditions, respectively.
Last week we covered Excel SUMIF that adds values meeting the specified criteria. Now it's
time to go over the plural version of SUMIF - Excel SUMIFS that allows summing values by
multiple criteria.
Those who are familiar with the SUMIF function might think that converting it to SUMIFS takes
just an extra "S" and a few additional criteria. This would seem quite logical... but "logical" it's
not always the case when dealing with Microsoft : )
sum_range - one or more cells to sum, required. This can be a single cell, a range of
cells or a named range. Only cells with numbers are summed; blank and text values are
ignored.
criteria_range1 - the first range to be evaluated by the associated criteria, required.
criteria1 - the first condition that must be met, required. You can supply the criteria in the
form of a number, logical expression, cell reference, text or another Excel function. For example
you can use criteria such as 10, ">=10", A1, "cherries" or TODAY().
criteria_range2, criteria2, ... - these are additional ranges and criteria associated with
them, optional. You can use up to 127 range/criteria pairs in SUMIFS formulas.
Important! The SUMIFS function works with AND logic, meaning that each cell in
the sum_range argument is summed only if all of the specified criteria are true for that cell.
And now, let's have a look at the Excel SUMIFS formula with two conditions. Suppose, you have
a table listing the consignments of fruit from different suppliers. You have the fruit names in
column A, suppliers' names in column B, and quantity in column C. What you want is to find out
a sum of amounts relating to a given fruit and supplier, e.g. all apples supplied by Pete.
When you're learning something new, it's always a good idea to start with simple things. So, to
begin with, let's define all the arguments for our SUMIFS formula:
sum_range - C2:C9
criteria_range1 - A2:A9
criteria1 - "apples"
criteria_range2 - B2:B9
criteria2 - "Pete"
Now assemble the above parameters, and you will get the following SUMIFS formula:
To refine the formula further, you can replace the text criteria "apples" and "Pete" with cell
references. In this case, you won't have to change the formula to calculate the quantity of other
fruit from a different supplier:
=SUMIFS(C2:C9, A2:A9, F1, B2:B9, F2)
Using SUMIFS and SUMIF in Excel - things to remember
Since the aim of this tutorial is to cover all possible ways to sum values by several conditions,
we will discuss formula examples with both functions - Excel SUMIFS and SUMIF with multiple
criteria. To use them correctly, you need to clearly understand what these two functions have in
common and in what way they are different.
While the common part is clear - similar destination and parameters - the differences are not so
obvious, though very essential.
1. The order of arguments
In Excel SUMIF and SUMIFS functions, the order of arguments is different. In particular,
sum_range is the 1st parameter in SUMIFS, but it is 3rd in SUMIF.
At first sight, it may seem that Microsoft deliberately complicates the learning curve for its users.
However, upon a closer look, you will see the reasoning behind it. The point is that sum_range
is optional in SUMIF. If you omit it, no problem, your SUMIF formula will sum values in the range
(first parameter).
In SUMIFS, the sum_range is very important and obligatory, and that is why it comes first.
Probably Microsoft guys thought that after adding the 10th or 100th range / criteria pair, someone
might forget to specify the range to sum : )
Wrapping up, if you are copying and editing these functions, make sure you put the parameters
in the right order.
2. The size of sum_range and criteria_range arguments
In the SUMIF function, the sum_range argument does not necessarily have to be of the same
size as the range argument, as long as you have the top left cell right. In Excel SUMIFS, each
criteria_range must contain the same number of rows and columns as the sum_range
parameter.
For example, =SUMIF(A2:A9,F1,C2:C18) will return the correct result because Excel considers
only the upper leftmost cell in the sum_range argument (C2 in this example, which is correct),
and then includes as many columns and rows as contained in the range argument.
The SUMIFS formula =SUMIFS(C2:C9, A2:A9, "apples", B2:B10, "Pete") will return the
#VALUE! error because criteria_range2 (B2:B10) does not match in size criteria_range1 (A2:A9)
and sum_range (C2:C9).
Alright, enough strategy (i.e. theory), let's get into the tactics (i.e. formula examples : )
How to use SUMIFS in Excel - formula examples
A moment ago, we discussed a simple SUMIFS formula with two text criteria. In the same
manner, you can use Excel SUMIFS with multiple criteria expressed by numbers, dates, logical
expressions, and other Excel functions.
Example 1. Excel SUMIFS with comparison operators
In our fruit suppliers table, suppose, you want to sum all deliveries by Mike with Qty. 200 or
more. To do this, you use the comparison operator "greater than or equal to" (>=) in criteria2
and get the following SUMIFS formula:
=SUMIFS(C2:C9,B2:B9,"Mike",C2:C9,">=200")
Note. Please pay attention that in Excel SUMIFS formulas, logical expressions with comparison
operators should always be enclosed in double quotes ("").
We covered all possible comparison operators in detail when discussing Excel SUMIF function,
the same operators can be used in SUMIFS criteria. For example, the following formula with
return the sum of all values in cells C2:C9 that are greater than or equal to 200 and less than or
equal to 300.
=SUMIFS(C2:C9, C2:C9,">=200", C2:C9,"<=300")
Example 2. Using Excel SUMIFS with dates
In case you want to sum values with multiple criteria based on the current date, use the
TODAY() function in your SUMIFS criteria, as demonstrated below. The following formula sums
values in column D if a corresponding date in column C falls within the last 7 days, including
today:
Note. When you use another Excel function together with a logical operator in the criteria, you
have to use the ampersand (&) to concatenate a string, for example "<="&TODAY().
In a similar fashion, you can use the Excel SUMIF function to sum values in a given date range.
For example, the following SUMIFS formula adds the values in cells C2:C9 if a date in column B
falls between 1-Oct-2014 and 31-Oct-2014, inclusive.
=SUMIFS(C2:C9, B2:B9, ">=10/1/2014", B2:B9, "<=10/31/2014")
The same result can be achieved by calculating the difference of two SUMIF functions, as
demonstrated in this example - How to use SUMIF to sum values in a given date range.
However, Excel SUMIFS is much easier and more understandable, isn't it?
Example 3. Excel SUMIFS with blank and non-blank cells
When analyzing reports and other data, you may often need to sum values corresponding either
to empty or non-empty cells.
Criteria
Description
"="
Sum values
corresponding to blank
cells that contain
absolutely nothing - no
formula, no zero length
string.
""
Sum values
Blank
cells
Formula Example
=SUMIFS(C2:C10, A2:A10, "=", B2:B10,
"=")
Sum values in cells C2:C10 if the
corresponding cells in columns A and B are
absolutely empty.
=SUMIFS(C2:C10, A2:A10, "", B2:B10, "")
corresponding to "visually"
blank cells including those
that contain empty strings
returned by some other
Excel function (for
example, cells with a
formula like ="").
Sum values
corresponding to nonempty cells, including zero
length strings.
Nonblank
cells
SUMSUMIF
or
SUM /
LEN
Sum values
corresponding to nonempty cells, not including
zero length strings.
=SUM((C2:C10) *
(LEN(A2:A10)>0)*(LEN(B2:B10)>0))
Sum values in cells C2:C10 if the
corresponding cells in columns A and B are
not empty, cells with zero length strings are
not included.
And now, let's see how you can use a SUMIFS formula with "blank" and "non-blank" criteria on
real data.
Suppose, you have an order date in column B, delivery date in column C and Qty. in column D.
How do you find the total of products that have not been delivered yet? That is, you want to
know the sum of values corresponding to non-empty cells in column B and empty cells in
column C.
The solution is to use the SUMIFS formula with 2 criteria:
As you see, the first SUMIF function adds the quantities corresponding to "Mike", the other
SUMIF function returns the amounts relating to "John" and then you add these 2 numbers.
As you see, an array criteria makes the formula much more compact compared to SUMIF +
SUMIF, and lets you add as many values as you like in the array.
This approach works with numbers as well as with text values. For instance, if instead of the
suppliers' names in column C, you had supplier IDs like 1, 2, 3 etc., then your SUMIF formula
would look similar to this:
=SUM(SUMIF(C2:C9, {1,2,3} , D2:D9))
Unlike text values, numbers needn't be enclosed in double quotes in array arguments.
Many people wonder why use double dash (--) in SUMPRODUCT formulas. The point is that
Excel SUMPRODUCT ignores all but numeric values, while the comparison operators in our
formula return Boolean values (TRUE / FALSE), which are non-numeric. To convert these
Boolean values to 1's and 0's, you use the double minus sign, which is technically called the
double unary operator. The first unary coerces TRUE/FALSE to -1/0, respectively. The second
unary negates the values, i.e. reverses the sign, turning them into +1 and 0, which the
SUMPRODUCT function can understand.
I hope the above explanation makes sense. And even if it doesn't, just remember this rule of the
thumb - use the double unary operator (--) when you are using comparison operators in your
SUMPRODUCT formulas.
Using Excel SUM in array formulas
As you remember, Microsoft implemented the SUMIFS function in Excel 2007. If someone still
uses Excel 2003, 2000 or earlier, you will have to use a SUM array formula to add values with
multiple AND criteria. Naturally, this approach works in modern versions of Excel 2013 - 2007
too, and can be deemed an old-fashioned counterpart of the SUMIFS function.
In the SUMIF formulas discussed above, you have already used array arguments, but an array
formula is something different.
Example 1. Sum with multiple AND criteria in Excel 2003 and earlier
Let's get back to the very first example where we found out a sum of amounts relating to a given
fruit and supplier:
As you already know, this task is easily accomplished using an ordinary SUMIFS formula:
=SUMIFS(C2:C9, A2:A9, "apples", B2:B9, "Pete")
And now, let's see how the same task can be fulfilled in early "SUMIFS-free" versions of Excel.
First off, you write down all the conditions that should be met in the form of range="condition". In
this example, we have two range/condition pairs:
Condition 1: A2:A9="apples"
Condition 2: B2:B9="Pete"
Then, you write a SUM formulas that "multiplies" all of your range/condition pairs, each
enclosed in brackets. The last multiplier is the sum range, C2:C9 in our case:
=SUM((A2:A9="apples") * ( B2:B9="Pete") * ( C2:C9))
As illustrated in the screenshot below, the formula perfectly works in the latest Excel 2013
version.
Note. When entering any array formula, you must press Ctrl + Shift + Enter. Once you do this,
your formula gets enclosed in {curly braces}, which is a visual indication that an array formula is
entered correctly. If you try typing the braces manually, your formula will be converted to a text
string, and it won't work.
Example 2. SUM array formulas in modern Excel versions
Even in modern versions of Excel 2013, 2010 or 2007, the power of the SUM function should
not be underestimated. The SUM array formula is not simply gymnastics of the mind, but has a
practical value, as demonstrated in the following example.
Suppose, you have two columns, B and C, and you need to count how many times column C is
greater than column B, when a value in column C is greater or equal to 10. An immediate
solution that comes to mind is using the SUM array formula:
=SUM((C1:C10>=10) * (C1:C10>B1:B10))
Don't see any practical application to the above formula? Think about it in another way : )
Suppose, you have the orders list like shown in the screenshot below and you want to know
how many products have not been delivered in full by a given date. Translated into Excel's
language, we have the following conditions:
Condition 1: A value in column B (Ordered items) is greater than 0
Condition 2: A value in column C (Delivered) in less than in column B
Condition 3: A date in column D (Due date) is less than 11/1/2014.
Putting the three range/condition pairs together, you get the following formula:
=SUM((B2:B10>=0)*(B2:B10>C2:C10)*(D2:D10<G2))
Well, the formula examples discussed in this tutorial have only scratched the surface of what
Excel SUMIFS and SUMIF functions can really do. But hopefully, they have helped pointing you
in the right direction and now you can sum values in your Excel workbooks no matter how many
intricate conditions you have to consider.
o
o
o
o
o
o
o
o
o
Note. Please pay attention that any text criteria or criteria containing mathematical symbols
must be enclosed in double quotation marks ("). For numerical criteria, double quotation marks
are not required.
3. sum_range - the cells to sum if the condition is met. This argument is optional, and you need
to use it only if you want to sum cells other than defined in the range argument. If the
sum_range argument is omitted, Excel will sum the same cells to which the criteria is applied
(i.e. specified in the range argument).
To illustrate the Excel SUMIF syntax better, let's consider the following example. Suppose you
have a list of products in column A and corresponding amounts in column C. You want to know
the sum of all amounts relating to a given product, e.g. bananas.
range - A2:A8
criteria - "bananas"
sum_range - C2:C8
Putting this together, you get: =SUMIF(A2:A8, "bananas", C2:C8)
This formula example demonstrates the simplest usage of the SUMIF function with the text
criteria. Instead of text, you can include a number, date or a cell references in your criteria. For
instance, you can re-write the above formula so that it references the cell containing the name
of the product to be summed:
=SUMIF(A2:A8,F1,C2:C8)
Note. The sum_range parameter actually specifies only the upper leftmost cell of the range to
be summed. The remaining area is defined by the dimensions of the range argument.
In practice, this means that the sum_range argument does not necessarily have to be of the
same size as the range argument, i. e. it may have a different number of rows and columns.
However, the first cell (i.e. the top left cell) of the sum range must always be the right one. For
example, in the above SUMIF formula, you can supply C2, or C2:C4, or even C2:C100 as the
sum_range argument, and the result will still be the same. However, the best practice is to
provide equally sized range and sum_range.
The point is that Microsoft Excel cannot rely on the user's ability to provide matching range and
sum_range parameters, so to avoid possible inconsistency issues and prevent errors, Microsoft
Excel determines the sum range on its own in the following way. It takes the top left cell in the
sum_range argument as the beginning cell (C2 in our Excel SUMIF example), and then includes
as many columns and rows as contained in the range argument (in our case, it's 1 column x 7
rows, i.e. C2:C8).
How to use SUMIF in Excel - formula examples
Hopefully, the above example has helped you to gain some basic understanding of how the
SUMIF function works. Below you will find a few more formulas that demonstrate how to use
SUMIF in Excel with various criteria and on different data sets.
SUMIF greater than, less than or equal to
Let's have a look at a few SUMIF formulas that you can use to add up values greater than, less
than or equal to a given value.
Note. Please pay attention that in Excel SUMIF formulas, a comparison operator followed by a
number or text should always be enclosed in double quotes ("").
Criteria
Operator
Formula Example
Description
Sum if
greater than
>
=SUMIF(A2:A10, ">5")
Sum if less
than
<
=SUMIF(A2:A10, "<10",
B2:B10)
Sum if equal
=SUMIF(A2:A10,
to
(can be
omitted)
"="&D1)
or
=SUMIF(A2:A10,D1)
Sum if not
equal to
<>
=SUMIF(A2:A10,
"<>"&D1, B2:B10)
Sum if
greater than
or equal to
>=
=SUMIF(A2:A10, ">=5")
Sum if less
than or equal
to
<=
=SUMIF(A2:A10,
"<=10", B2:B10)
Sum if
equal to
Sum if
not equal
to
Formula Example
Description
Exact match:
=SUMIF(A2:A8,
"bananas", C2:C8)
Partial match:
=SUMIF(A2:A8,
"*bananas*",
C2:C8)
Exact match:
=SUMIF(A2:A8,
"<>bananas",
C2:C8)
Partial match:
=SUMIF(A2:A8,
"<>*bananas*",
C2:C8)
For more information about partial match, please see SUMIF examples with wildcard
characters.
And now, let's see the exact "Sum if not equal to" formula in action. As illustrated in the
screenshot below, it adds in-stock amounts of all products other than "goldfinger bananas":
=SUMIF(A2:A7,"<> goldfinger bananas", C2:C7)
Note. Like most of other Excel functions, SUMIF is case-insensitive, meaning that "<>bananas",
"<>Bananas" and "<>BANANAS" will produce exactly the same result.
Using comparison operators with cell references
If you want to take a step further and get a more universal Excel SUMIF formula, you can
replace a numerical or text value in the criteria with a cell reference, like this:
=SUMIF(A2:A8,"<>"&F1, C2:C8)
In this case, you won't have to change the formula to conditionally sum values based on another
criteria - you will simply type a new value in a referenced cell.
Note. When you use a logical expression with a cell reference, you must use the double quotes
("") to start a text string and ampersand (&) to concatenate and finish the string off, for example
"<>"&F1.
The "equal to" operator (=) can be omitted before a cell reference, therefore both of the below
formulas are equivalent and correct:
Formula 1: =SUMIF(A2:A8, "="&F1, C2:C8)
Formula 2: =SUMIF(A2:A8, F1, C2:C8)
SUMIF formulas with wildcard characters
If you aim to conditionally sum cells based on a "text" criteria and you want to sum by partial
match, then you need to use wildcard characters in your SUMIF formula.
The following wildcards are available to us:
If you want to count only those cells that start or end with certain text, add just one * either
before or after the text:
Note. If there are 2 or more numbers that are tied for last place, only the first will be included. As
you see, the second 9 is not added up in the above example.
Remember, these are array formulas, so you have to press Ctrl + Shift + Enter to complete
them.
How to sum cells that correspond to blank cells
If "blank" means cells that contain absolutely nothing - no formula, no zero length string returned
by some other Excel function, then use "=" as the criteria, like in the following SUMIF formula:
=SUMIF(A2:A10,"=",C2:C10)
If "blank" includes zero length strings (for example, cells with a formula like =""), then use "" as
the criteria:
=SUMIF(A2:A10,"",C2:C10)
Both of the above formulas evaluate cells in column A and if any empty cells are found, the
corresponding values from column C are added.
Sum values if a
corresponding date is
greater than or equal
to a given date.
Sum values if a
corresponding date is
greater than a date in
another cell.
Formula Example
Description
=SUMIF(B2:B9,"10/29/2014",C2:C9)
=SUMIF(B2:B9,">=10/29/2014",C2:C9)
=SUMIF(B2:B9,">"&F1,C2:C9)
In case you want to sum values based on a current date, then you have to use Excel SUMIF in
combination with the TODAY() function as demonstrated below:
Criteria
Formula Example
=SUMIF(B2:B9, "<"&TODAY(),
C2:C9)
=SUMIF(B2:B9, ">"&TODAY(),
C2:C9)
=SUMIF(B2:B9, "="&TODAY()+7,
C2:C9)
The screenshot below illustrates how you can use the last formula to find the total amount of all
products that ship in a week.
This formula sums up the values in cells C2:C9 if a date in column B is between 1-Oct-2014 and
31-Oct-2014, inclusive.
This formula might seem a bit tricky at first sight, but upon a closer look, it appears quite simple.
The first SUMIF function adds up all the cells in C2:C9 where the corresponding cell in column
B is greater than or equal to the start date (Oct-1 in this example). Then you just have to
subtract any values that fall after the end date (Oct-31), which are returned by the second
SUMIF function.
How to sum values in several columns
To understand the problem better, let's consider the following example. Suppose, you have a
summary table of monthly sales. Since it was consolidated from a numbers of regional reposts,
there are a few records for the same product:
So, how do you find the total of apples sold in all the states in the past three months?
As you remember, the dimensions of sum_range are determined by the dimensions of the range
parameter. That is why you cannot use the formula like =SUMIF(A2:A9,"apples",C2:E9)
because it will add up the values corresponding to "Apples" in column C only. This is not what
we are looking for, right?
The most logical and simplest solution that suggests itself is to create a helper column that
calculates individual sub-totals for each row and then reference that column in the sum_range
criteria.
Go ahead and place a simple SUM formula in cell F2, then fill down column F: =SUM(C2:E2)
After that, you can write a usual SUMIF formula like this:
=SUMIF(A2:A9, "apples", F2:F9)
or
=SUMIF(A2:A9, H1, F2:F9)
In the above formulas, sum_range is exactly of the same size as range, i.e. 1 column and 8
rows, and therefore they return the correct result:
If you'd rather do without a helper column, then you can write a separate SUMIF formula for
each of the columns you want to sum, and then add the returned numbers using the SUM
function:
=SUM(SUMIF(A2:A9,I1,C2:C9), SUMIF(A2:A9,I1,D2:D9), SUMIF(A2:A9,I1,E2:E9))
Another way is using a more complex array formula (don't forget to press Ctrl + Shift + Enter):
{=SUM((C2:C9+D2:D9+E2:E9)*(--(A2:A9=I1)))}
Both of the above formulas will return 2070 in our case.
The Excel SUMIF examples described in this tutorial only touch on some of the basic usages of
this function. In the next article, we'll investigate advanced formulas that harness the real power
of SUMIF and SUMIFS and let you sum by multiple criteria. Please stay tuned and thank you for
reading!
Convert text-formatted digits to number using Excel VALUE function and other options
In this article, I'll show you how to convert text digits to number using several options in Excel
2010-2013. You'll see how to make Excel treat digits as numbers with the help of the VALUE
function, error checking, Paste Special and applying the number format. Those who want to
automate the task will find a helpful VBA macro and a special add-in.
In my previous article, I described how to convert number to text. Today I'll show you this
process reversed. You may have at least three reasons to convert text-formatted numbers in
Excel.
Tip. In case you want to translate words to digits, like "seven" to 7, please see English words
into numbers on our Blogs.
Use Error Checking to convert text-formatted numbers
Apply a number format to digits stored as text
Use the Paste special functionality to convert text to number in Excel
Turn text to number using the Excel VALUE function
Grab a VBA macro to convert text to numbers
Cell Cleaner - turn numbers stored as text to numbers
Use Error Checking to convert text-formatted numbers
Have you ever noticed small green triangles in the upper-left corner of cells containing
numbers? These error indicators may appear if you import numeric data into Excel from an
external source, or if you enter numbers into cells formatted as text. These green triangles tell
Below you'll find the steps helping to get rid of these Number Formatted as Text errors.
1. Select any cell in your table that contains a green error indicator in the upper-left corner.
Tip. You can use one of the following keyboard shortcuts to select a range.
Ctrl + A - selects the entire contiguous range.
Ctrl + A Twice - picks the entire sheet.
Ctrl + Space Bar - highlights the entire column.
Shift + Left/Right Arrow - selects multiple columns.
Shift + Space Bar - picks the entire row.
Shift + Up/Down Arrow - selects multiple rows.
2. Click on the error button with the Exclamation mark next to the selected cell or range.
3. You will see a drop-down menu. Just select the option Convert to Number.
Tip. If you just want to get rid of the green triangle in the upper-left corner of cells without
turning text to number, select the Ignore Error option.
All the digits stored as text will convert back to number format and the content will be aligned to
the right. As soon as they become regular numbers, you can choose to apply or customize
number format.
Apply a number format to digits that are stored as text
Before selecting the correct number format, please make sure the cells with the values you want
to convert don't contain any leading or trailing spaces. You can use the Trim function to remove
them.
1. Select the text-formatted numbers you want to convert to number format in your table.
2. Navigate to the Home tab -> Number group.
3. Select the necessary format from the Number Format drop-down list.
4. To get the extended set of the number formatting options, click on the Dialog Box
Launcher next to Number.
5. You will see the Format Cells window. Select the necessary category in the list under
the Numbertab to see all possible customizations.
4. Click on the Add radio button in the Operation section and press Ok.
You will see the cells alignment change to the right, which means now your numerical values
are treated as numbers.
Turn text to number using the Excel VALUE function
Using the VALUE function in Excel is the best option to convert text to number if you need to
process the data further or if there are excess leading and trailing spaces that need to be
removed. For a better result, you can process the cell contents using the clean and text function
that will delete non-printing characters and extra spaces correspondingly. Here is the function
you can copy across: =value(trim(clean(A2)))
The Excel VALUE Function converts a text string into number. The syntax is: VALUE( text ).
Here text is a text string that can be translated into a number.
Note. If text is not formatted as constant number, date, or time the function returns
the #VALUE! error.
1. Create a helper column and click on its first cell.
2. In the Formula bar enter =value(range address). In my example the range address is
A1:A10.
3. Copy the formula across the helper column using the fill handle to see the alignment
automatically change to the right and the green error indicators disappear.
3. Press the Convert numbers stored as text to numbers radio button and click Convert.
Using this feature will not only format your numbers correctly, but it will remove spaces and
apostrophes.
Besides converting text to numbers this helpful tool can trim extra spaces, change case in
Excel, replace or remove unwanted characters and much more. You can visit the Cell Cleaner
webpage to explore all its possibilities.
Hope this article helped you choose the best solution for converting text to number format in
Excel. Stay tuned for more helpful articles about Excel and feel free to leave your questions in
the comments below. Be happy and excel in Excel!
How to convert numbers to text using Excel TEXT function and other options
This tutorial shows how to convert number to text in Excel 2010-2013. See how to accomplish
the task with the Excel TEXT function and use number to string to specify the formatting. Learn
how to change number format to text with the Format Cells and Text to Columns options.
If you use Excel spreadsheets to store long and not so long numbers, one day you may need to
convert them to text. There may be different reasons to change digits stored as numbers to text.
Below you'll find why you may need to make Excel see the entered digits as text, not as
number.
Search by part not by the entire number. For example, you may need to find all numbers
that contain 50, like in 501, 1500, 1950, etc.)
It may be necessary to match two cells using the VLOOKUP or MATCH function.
However, if these cells are formatted differently, Excel will not see identical values as matching.
For instance, A1 is formatted as text and B1 is number with format 0. The leading zero in B2 is a
custom format. When matching these 2 cells Excel will ignore the leading 0 and will not show
the two cells as identical. That's why their format should be unified.
The same issue can occur if the cells are formatted as ZIP code, SSN, telephone number,
currency, etc.
Note. If you want to convert numbers to words like amount to text, it's a different task. Please
check the article about spelling numbers named Two best ways to convert numbers to words in
Excel.
In this article I'll show you how to convert numbers to text with the help of the Excel TEXT
function. If you are not so formula-oriented, have a look at the part where I explain how to
change digits to text format with the help of the standard Excel Format Cells window, by adding
an apostrophe and employing the Text to Columns wizard.
with text or symbols. The TEXT function converts a numeric value to formatted text, thus the
result cannot be calculated.
If you are familiar with using formulas in Excel, it will not be a problem for you to employ the
TEXT function.
1. Add a helper column next to the column with the numbers to format. In my example, it's
column D.
2. Enter the formula =TEXT(C2,"0") to the cell D2. In the formula, C2 is the address of the first
cell with the numbers to convert.
3. Copy the formula across the column using the fill handle.
4. You will see the alignment change to left in the helper column after applying the formula.
5. Now you need to convert formulas to values in the helper column. Start with selecting the
column.
6. Use Ctrl+C to copy. Then press the Ctrl+Alt+V shortcut to display the Paste Special dialog
box.
7. On the Paste Special dialog, select the Values radio button in the Paste group.
You will see a tiny triangle appear in the top-left corner of each cell in your helper column, which
means the entries are now text versions of the numbers in your main column.
Now you can either rename the helper column and delete the original one, or copy the results to
your main and remove the temporary column.
Note. The second parameter in the Excel TEXT function shows how the number will be
formatted before being converted. You may need to adjust this based on your numbers:
The result of =TEXT(123.25,"0") will be 123.
The result of =TEXT(123.25,"0.0") will be 123.3.
The result of =TEXT(123.25,"0.00") will be 123.25.
Tip. You can display the Format Cells window by pressing the Ctrl+1 shortcut.
3. On the Format Cells window select Text under the Number tab and click OK.
You'll see the alignment change to left, so the format will change to text. This option is good if
you don't need to adjust the way your numbers will be formatted.
Add an apostrophe to change number to text format
If these are just 2 or 3 cells in Excel where you want to convert numbers to string, benefit from
adding an apostrophe before the number. This will instantly change the number format to text.
Just double-click in a cell and enter the apostrophe before the numeric value.
You will see a small triangle added in the corner of this cell. This is not the best way to convert
numbers to text in bulk, but it's the fastest one if you need to change just 2 or 3 cells.
Convert numbers to text in Excel with Text to Columns wizard
You may be surprised but the Excel Text to Columns option is quite good at converting numbers
to text. Just follow the steps below to see how it works.
1. Select the column where you want to convert numbers to string in Excel.
2. Navigate to the Data tab in and click on the Text to Columns icon.
3. Just click through steps 1 and 2. On the third step of the wizard, make sure you select
the Textradio button.
Manager > New) or typing the name directly in the Name Box.
Note. Please pay attention that if your first row is sort of column header like you see in the
screenshot above, you shall not include it in the named range.
For the detailed step-by-step instructions please see Creating a named range.
Things to remember:
1.
The items to appear in the first drop-down list must be one-word entries,
e.g. Apricot, Mango,Oranges. If you have items consisting of two, three or more words,
please see How to create a cascading dropdown with multi-word entries.
2.
The names of the dependent lists must be exactly the same as the matching entry in
main list. For example, the dependent list to be displayed when "Mango" is selected from the
first drop-down list should be named Mango.
When done, you may want to press Ctrl+F3 to open the Name Manager window and check if all
of the lists have correct names and references.
For the detailed steps, please see Making a drop down list based on a named range.
As the result, you will have a drop-down menu in your worksheet similar to this:
If cell A2 is currently empty, you will get the error message "The Source currently evaluates to
an error. Do you want to continue?"
Safely click Yes, and as soon as you select an item from the first drop-down menu, you will see
the entries corresponding to it in the second, dependent, drop-down list.
Now, each time you select India under the list of countries in column B, you will have the
following choices in the third drop-down:
Note. The displayed list of regions is unique for each country but it does not depend on the
selection in the first drop-down list.
Create a third dropdown dependent on the first two lists
If you need to create a cascading drop down menu that depends on the selections both in the
first and second drop-down lists, then proceed in this way:
1. Create additional sets of named ranges, and name them for the word combinations in your
first two dropdowns. For example, you have Mango, Oranges, etc. in the 1st list and India,
Brazil, etc. in the 2nd. Then you create named
ranges MangoIndia, MangoBrazil, OrangesIndia, OrangesBrazil, etc. These names should not
2. Apply Excel Data Validation with the INDIRECT / SUBSTITUTE formula that concatenates the
names of the entries in the first two columns, and removes the spaces from the names. For
example, in cell C2, the data validation formula would be:
=INDIRECT(SUBSTITUTE(A2&B2," ",""))
Where A2 and B2 contain the first and second dropdowns, respectively.
As the result, your 3rd drop-down list will display the regions corresponding to
the Fruit andCountry selected in the first 2 drop-down lists.
This is the easiest way to create cascading drop-down boxes in Excel. However, this method
has a number of limitations.
Limitations of this approach:
1. The items in your primary drop-down list must be one-word entries. See how to
createcascading drop-down lists with multi-word entries.
2. This method won't work if the entries in your main drop-down list contain characters not
allowed in range names, such as the hyphen (-), ampersand (&), etc. The solution is to create
adynamic cascading dropdown that does not have this restriction.
3. Drop-down menus created in this way are not updated automatically i.e. you will have to
change the named ranges' references every time you add or remove items in the source lists.
To get over this limitation, try making a dynamic cascading drop down list.
How to create cascading drop-down lists with multi-word entries
The INDIRECT formulas like we used in the example above can handle one-word items only.
For example, the formula =INDIRECT(A2) indirectly references cell A2 and displays the named
range exactly with the same name as is in the referenced cell. However, spaces are not allowed
in Excel names, which is why this formula won't work with multi-word names.
The solution is to use the INDIRECT function in combination with SUBSTITUTE like we did
when creating a 3rd dropdown.
Suppose you have Water melon among the products. In this case, you name a list of water
melon exporters with one word without spaces - Watermelon.
Then, for the second dropdown, apply Excel Data Validation with the following formula that
removes the spaces from the name in cell A2:
=INDIRECT(SUBSTITUTE(A2," ",""))
Where B2 contains the second dropdown, "Fruit" is the name of the list that appears in the first
drop-down menu, and "FakeList" is any fake name that does not exist.
Now, if any item is selected in the 2nd drop-down list, no choices will be available when the user
clicks on the arrow next to the first list.
Creating dynamic cascading drop-down lists in Excel
The main advantage of a dynamic Excel dependent drop-down list is that you are free to edit the
source lists and your drop-down boxes will get updated on the fly. Of course, creating dynamic
dropdowns requires a bit more time and more complex formulas, but I believe this is a worthy
investment because once set up, such drop-down menus are real pleasure to work with.
As with almost anything in Excel, you can achieve the same result in several ways. In particular,
you can create a dynamic dropdown using a combination of OFFSET, INDIRECT and COUNTA
functions or a more resilient INDEX / MATCH. The latter is my preferred way because it
provides numerous advantages, the most essential of which are:
1.
2.
3.
4.
5.
You have to create 3 named ranges only, no matter how many items there are in the
main and dependent lists.
Your lists may contain multi-word items and any special chars.
The number of entries can vary in each column.
The entries' sort order does not matter.
Finally, it's very easy to maintain and modify the source lists.
Microsoft Excel will use the built-in table reference system to create the name of
thetable_name[#Headers] pattern.
Give it some meaningful and easy to remember name, e.g. fruit_list, and click OK.
2.2. Create a name for the cell containing the first drop-down list.
I know that you don't have any dropdown yet :) But you have to choose the cell to host your first
dropdown and create a name for that cell now because you will need to include this name in the
third name's reference.
For example, my first drop-down box is reside in cell B1 on Sheet 2, so I create a name for it,
something simple and self-explanatory like fruit:
If you are curious to learn the Index and Match functions in-depth, check out this tutorial: INDEX
& MATCH - a better alternative to VLOOKUP.
Well, you have already done the major part of the work! Before getting to the final step, it may
be a good idea to open the Name Manager (Ctrl + F3) and verify the names and references:
For the first drop-down list, in the Source box, enter =fruit_list (the name created in step
2.1).
For the dependent drop-down list, enter =exporters_list (the name created in step 2.3).
Done! Your dynamic cascading drop-down menu is accomplished and will update automatically
reflecting the changes you've made to the source table.
This dynamic Excel dropdown, perfect in all other respects, has one shortcoming - if the
columns of your source table contain a different number of items, the blank rows will appear in
Note. When working with dynamic cascading drop down lists created with the above formulas,
nothing prevents the user from changing the value in the first dropdown after making the
selection in the second menu, as a result, the choices in the primary and secondary dropdowns
may mismatch. You can block changes in the first box after a selection is made in the second
one by using either VBA or complex formulas suggested in this tutorial.
This is how you create dynamic cascading drop-down lists in Excel. Feel free to download the
sample workbooks and see it in action:
Creating a drop down list in Excel: static, dynamic, from another workbook
The tutorial demonstrates 4 quick ways to create an Excel drop down list - based on a list of
values, range of cells, named range and a dynamic dropdown. It also shows how to create a
dropdown from another workbook, edit and delete Data Validation lists.
Excel drop-down list, aka drop down box or combo box, is used to enter data in a spreadsheet
from a pre-defined items list. The main purpose of using drop down lists in Excel is to limit the
number of choices available for the user. Apart from that, a dropdown prevents spelling
mistakes and makes data input faster.
o
o
You can even select non-contiguous cells by pressing and holding the Ctrl key while selecting
the cells with the mouse.
Now, Excel users simply click an arrow next to a cell containing a dropdown box, and then
select the entry they want from the drop down menu.
Well, your drop-down box is ready in under a minute. However, this is not the best way to create
an Excel drop-down list, especially if you want the same list to appear in multiple cells, and
here's why...
If you want to edit your Excel drop down list at some point in the future, you would have
tochange every cell that references the Data Validation list. This may not be a big deal if you
have just a few such cells residing on the same sheet, but if you have dozens or hundreds
scattered across different worksheets, it may take quite a while to locate and edit them all.
Anyway, if you decide to stick with this easiest approach, see the detailed guidance on how
to edit a comma-separated drop-down list.
Tip. It's a good idea to sort your entries in the order you want them to appear in the drop-down
menu.
2. Create a named range.
You can actually skip this step and create your drop-down list based on a range of cells, but
named ranges really make managing Excel drop-down lists easier.
Select all the entries you want to include in the drop down list, right-click them, and
chooseDefine Name from the context menu. Alternatively, you can click Name Manager on
theFormulas tab or press Ctrl + F3.
In the Name Manager dialog, click New.
In the Name field, type a name for your entries, make sure the correct range is displayed
in theRefers to box, and then click OK. Be sure your range name doesn't have any spaces or
hyphens, use underscores (_) instead.
Tip. A faster way to create a named range in Excel is to select the cells and type the range
name directly in the Name Box. When finished, click Enter to save the newly created named
range.
Why you may want to use a table? First and foremost, because it lets you create a dynamic
drop-down list and sets you free from the necessity toupdate the named range reference when
you remove or add new items to the source list.
3. Select the location for your drop-down list.
Simply click in the cell where you want to have the drop-down list. This can be in the same
sheet where your list of entries is located or in a different worksheet. You can also select a
range of cells, or the entire column.
Note. Excel 2003 and older require the dropdown list to be on the same worksheet.
If the source list contains more than 8 items, your drop-down box will have a scroll bar like this:
the latter, you simply go to the other sheet and select a range using a mouse.
The main advantage of dynamic drop-down lists is that you won't have to change the reference
to the named range every time after editing the source list. You simply delete or type new
entries in the source list and all of the cells containing this Data Validation list will get updated
automatically!
The OFFSET function in detail
If you are curious to get the logic of the above formula, here you go.
In Microsoft Excel, the OFFSET function returns a reference to a range consisting of a specified
number of rows and columns. You can use it in various scenarios when you need to get a
dynamic, i.e. continuously changing, range.
The syntax of the OFFSET function is as follows:
OFFSET(reference, rows, cols, [height], [width])
reference - the first cell or a range of adjacent cells from which you want to base the
offset.
rows - the number of rows, up or down, that you want the upper-left cell of the returned
range to refer to.
cols - similar to rows, i.e. the number of columns, to the left or right, for the upper-left
cell of the returned range to refer to.
height, optional - the number of rows in the returned range.
width, optional - the number of columns in the returned range.
reference - cell $A$1 in Sheet1, which is the first item of your drop-down list;
rows & cols are 0 because you don't want to shift the returned range either vertically or
horizontally;
height - the number of non-empty cells in column A, returned by the COUNTA function;
width - 1, i.e. one column.
Creating a drop-down list from another workbook
You can make a drop-down menu in Excel using a list from another workbook as the source. To
do this, you will have to create 2 named ranges - one in the source book and another in the
book where you wish to use the Data Validation list.
Note. For the drop-down list from another workbook to work, the workbook with the source list
must be open.
A static dropdown list from another workbook
The dropdown list created in this way won't update automatically when you add or remove
entries in the source list and you will have to modify the source list reference manually.
1. Create a named range for the source list.
Open the workbook that contains the source list, SourceBook.xlsx in this example, and create a
named range for the entries you want to include in your drop-down list, e.g. Source_list.
Source_list
Note. You have to enclose the workbook's name in apostrophes (') if it contains any spaces. For
example: ='Source Book.xlsx'!Source_list
3. Apply Data Validation
In the main workbook, select the cell(s) for your drop-down list, click Data > Data Validation and
enter the name you created in step 2 in the Source box.
1. Create a range name in the Source workbook with the OFFSET formula, as explained
in Creating a dynamic drop-down.
2. In the main workbook, apply Data Validation in the usual way.
Data Validation does not work
The Data Validation option is greyed out or disabled? There are a few reasons why that might
happen:
In the Data Validation dialog (Data tab > Data Validation), switch to the Input
Message tab.
Make sure the option Show input message when cell is selected is checked.
Type a title and message in the corresponding fields (up to 225 characters).
Click the OK button to save the message and close the dialog.
in the combo box. The options differ only in the icon displayed along with the message and the
button selected by default.
And this is how your customized warning message may look like in Excel:
Tip. If you are not sure what title or message text to type, you can leave the fields empty. In this
case, Microsoft Excel will display the default alert "The value you entered is not valid. A user
has restricted values that can be entered into this cell."
4. Click OK to save the changes and close the Excel Data Validation window.
5. Click the OK button to save the changes and close the window.
Tip. If you want to apply the changes to all the cells containing this drop-down list, select the
"Apply these changes to all other cells with the same settings" option.
Editing an Excel drop-down list based on a named range
If you have created a named range based drop-down box, then you can just edit your range's
items and then change the reference to the Named Range. All drop-down boxes based on this
named range will get updated automatically.
On the Excel ribbon, go to the Formulas tab > Name Manager. Alternatively, press Ctrl +
F3 to open the Name Manager window.
In the Name Manager window, select the named range you want to update.
Change the reference in the Refers to box by clicking the range selection icon
and
selecting all the entries for your drop-down list.
Click the Close button, and then in the confirmation message that appears, click Yes to
save your changes.
Tip. To avoid the necessity to update the named range's references after each change of the
source list, you can create a dynamic Excel drop-down menu. In this case, your dropdown list
will get updated automatically in all associated cells as soon as you remove or add new entries
to the list.
How to delete a drop-down list
If you no longer want to have drop-down boxes in your Excel worksheet, you can remove them
from some or all cells.
This method removes the drop-down menus from the selected cells, but keeps the currently
selected values.
If you want to delete both a dropdown and the cells' values, you can select the cells and click
theClear all button on the Home tab > Editing group > Clear.
Deleting an Excel drop-down list from all cells in the current sheet
In this way, you can remove a drop-down list from all associated cells in the current worksheet.
This won't delete the same drop-down box from cells in other worksheets, if any.
1. Select any cell containing your drop-down list.
2. Click Data Validation on the Data tab.
3. In the Data Validation window, on the Settings tab, select the "Apply these changes to all
other cells with the same settings" check box.
Once you check it, all of the cells referencing this Excel Data Validation list will get selected, as
you can see in the screenshot below.
4. Click the Clear All button to delete the drop-down list.
5. Click OK to save the changes and close the Data Validation window.
This method deletes a drop-down list from all the cells containing it, retaining the currently
selected values. If you created a dropdown based on a range of cells or based on a named
range, the source list will also remain intact. To remove it, open the worksheet containing the
drop-down list's items, and delete them.
Now you know the basics of Excel drop-down lists. In the next article, we will explorer this topic
further and I will show you how to create dependent drop down lists with conditional Data
Validation and how to create a drop-down box from another workbook. Please stay tuned and
thank you for reading!
Excel VLOOKUP not working - solutions for N/A, NAME and VALUE errors
The tutorial explains how you can quickly cope with VLOOKUP not working problems in Excel
2013, 2010, 2007 and 2003, troubleshoot and fix common errors and overcome VLOOKUP's
limitations.
In the last few articles, we have explored different aspects of the Excel VLOOKUP function. If
you have been following us closely, by now you should be an expert in this area : )
However, it's not without a reason that many Excel specialists consider VLOOKUP to be one of
the most intricate Excel functions. It has a ton of limitations and specificities, which are the
source of various problems and errors.
If the lookup value is smaller than the smallest value in the lookup array.
If the lookup column is not sorted in ascending order.
3. #N/A in exact match VLOOKUP
If you are searching with exact match (range_lookup argument set to FALSE) and the exact
value is not found, the #N/A error is also returned. See more details on how to properly
use exact and approximate match VLOOKUP formulas.
4. The lookup column is not the leftmost column of the table array
As you probably know, one of the most significant limitations of Excel VLOOKUP is that it
cannot look to its left, consequently your lookup column should always be the left-most column
in the table array. In practice, we often forget about this and end up with VLOOKUP not
working because of the N/A error.
Solution: If it is not possible to restructure your data so that the lookup column is the left-most
column, you can use a combination of Excel's INDEX and MATCH functions, as a more versatile
alternative to VLOOKUP. You will find the detailed info and a formula example in this tutorial
-INDEX / MATCH formula to lookup values to left.
5. Numbers are formatted as text
Another source N/A errors in VLOOKUP formulas is numbers being formatted as text, either in
the main or lookup table.
This usually occurs when you import data from some external database or if you've typed an
apostrophe before a number to indicate a leading zero.
The most obvious indications of numbers being formatted as text are shown in the screenshot
below.
The numbers can also be stored in the General format. In this case, there's only one noticeable
sign - numbers get aligned to the left side of a cell, while numbers stored as numbers are
aligned to the right by default.
Solution: If this is just a single number, simply click on the error icon and choose "Convert To
Number" from the context menu.
If multiple numbers are affected, select them all, right-click the selection, then choose Format
Cells> Number tab > Number and click OK.
6. Excess leading or trailing spaces
This is the least obvious cause of the Vlookup N/A error because a human eye can hardly spot
those extra spaces, especially when working with big tables where most of the entries are below
the scroll.
Solution 1: Extra spaces are in the main table (with VLOOKUP formulas)
If excess spaces occur in your main table, you can ensure the correct work of your Vlookup
formulas by wrapping the lookup_value argument with the TRIM function:
=VLOOKUP(TRIM($F2),$A$2:$C$10,3,FALSE)
If extra spaces occur in the lookup column, there is no easy way to avoid VLOOKUP #N/A
errors. Instead of VLOOKUP, you can use an array formula with a combination of INDEX /
MATCH and TRIM functions:
=INDEX($C$2:$C$10,MATCH(TRUE,TRIM($A$2:$A$10)=TRIM($F$2),0))
Since this is an array formula, don't forget to press Ctrl + Shift + Enter rather than a usual Enter
keystroke to properly complete it:
For more information about using INDEX / MATCH in Excel, please check out this
tutorial: INDEX & MATCH in Excel - a better alternative to VLOOKUP.
Tip. A quick alternative to complex INDEX / MATCH formulas is running the Trim Spaces for
Excel add-in that will eliminate excess spaces both in the lookup and main tables in seconds,
making your VLOOKUP formulas error-free. This is a free tool and you can find the download
link on the above page.
#VALUE error in VLOOKUP formulas
In general, Microsoft Excel displays the #VALUE! error if a value used in the formula is of a
wrong data type. In respect to VLOOKUP, there are two common sources of the VALUE! error.
1. Lookup value exceeds 255 characters
Please be aware that the VLOOKUP function cannot look up values containing 256 characters
or more. If your lookup values exceed this limit, you will end up having the VALUE error:
Solution: Use an analogous INDEX /MATCH formula instead. In the above example, the
following INDEX / MATCH function works perfectly:
=INDEX(C2:C7,MATCH(TRUE,INDEX(B2:B7= F$2,0),0))
You can learn more about using INDEX / MATCH in Excel in this tutorial.
2. Full path to the lookup workbook is not supplied
If you are pulling data from another workbook, you have to include the full path to that file. More
precisely, you have to enclose the workbook's name (including the extension) in square
brackets [], and then specify the sheet's name followed by the exclamation mark. Also, you
should have apostrophes around all this in case either a workbook or spreadsheet name
contains spaces.
Here's the structure of the complete formula to do a vlookup from another workbook:
=VLOOKUP(lookup_value, '[workbook name]sheet name'!table_array,
col_index_num, FALSE)
A real formula might look similar to this:
=VLOOKUP($A$2,'[New Prices.xls]Sheet1'!$B:$D,3,FALSE)
The above formula will search for the value of cell A2 in column B of Sheet1 in the "New Prices"
workbook, and return a matching value from column D.
If any element of the path is missing, your VLOOKUP formula won't work and return the
#VALUE error (unless the lookup workbook is currently open).
For more info about VLOOKUP formulas referencing another Excel file, please check out this
tutorial: How to do vlookup from a different workbook.
3. The col_index_num argument is less than 1
It's hard to imagine a situation when someone would want to enter a number less than "1" to
specify the column to return values from. Though, it may happen if this argument is returned by
some other Excel function nested in your Vlookup formula.
So, if the col_index_num argument happens to be less than 1, your Vlookup formula will return
the #VALUE! error too.
If the col_index_num argument is greater than the number of the columns in the specified table
array, Vlookup formulas return the #REF! error.
VLOOKUP #NAME error
This is the easiest case - the NAME error appears if you've accidentally misspelled the
function's name.
The solution is obvious - check the spelling : )
Excel VLOOKUP not working (limitations, issues and solutions)
Apart from having a fairly complicated syntax, VLOOKUP has arguably more limitations than
any other Excel function. Because of these limitations, seemingly correct Vlookup formulas
might often deliver results different from what you expect. Below you will find solutions for a few
common scenarios when VLOOKUP fails.
1. VLOOKUP is case-insensitive
The VLOOKUP function does not distinguish case and teats lowercase and UPPERCASE
characters as identical. So, if your table includes several similar entries that differ in the
uppercase or lowercase chars only, the Vlookup formula will return the first found value
regardless of the case.
Solution: Use another Excel function that can do a vertical lookup (LOOKUP, SUMPRODUCT,
INDEX / MATCH) in combination with the EXACT function that can match case. You can find the
Meaning, you enter the value to check for an error in the 1st argument, and in the 2nd argument
you specify what to return if an error occurs.
For example, the following IFERROR / VLOOKUP formula returns a blank cell when the lookup
value is not found:
=IFERROR(VLOOKUP($F$2,$B$2:$C$10,2,FALSE),"")
If you'd rather display your own message instead of a standard Vlookup error, type it between
the quotation marks, like this:
=IFERROR(VLOOKUP($F$2,$B$2:$C$10,2,FALSE),"Oops, no match is found.
Please try again!")
How to remove rows based on a cell value: shortcuts, VBA macros, delete every other
row
This article lists several ways to delete rows in Excel 2010-2013 based on a cell value. In this
post you'll find hotkeys as well as Excel VBA. Delete rows automatically or use the standard
Find option in combination with helpful shortcuts.
Excel is a perfect tool to store data that change every now and then. However, updating your
table after some changes may need really much time. The task can be as simple as removing
all blank rows in Excel. Or you may need to find and delete the duplicated data. One thing we
know for sure is that whenever details come or go, you search for the best solution to help you
save time on the current work.
For example, you have a marketplace where different vendors sell their products. For some
reason one of the vendors closed their business and now you need to delete all rows that
contain the vendor's name, even if they are in different columns.
In this post you'll find Excel VBA and shortcuts to delete rows based on certain text or value.
You'll see how to easily find and select the necessary information before removing. If your task
is not about deleting but adding rows, you can find how to do it in Fastest ways to insert multiple
rows in Excel 2010-2013.
o
o
You can also select entire lines using the row number buttons. You'll see the number of the
highlighted rows next to the last button.
After you select the necessary rows, you can quickly remove them using an Excel "delete row"
shortcut. Below you'll find how to get rid of the selected lines whether you have a standard data
table, or a table that has data to the right.
Remove rows from the entire table
If you have a simple Excel list that has no additional information to the right, you can use the
delete row shortcut to remove rows in 2 easy steps:
1. Select the rows you want to delete.
2. Press the Ctrl + - (minus on the main keyboard) hotkey.
You'll see the unused rows disappear in a snap.
Tip. You can highlight only the range that contains the values you want to remove. Then use the
shortcut Ctrl + - (minus on the main keyboard) to get the standard Excel Delete dialog box
allowing you to select the Entire row radio button, or any other deleting option you may need.
If that's your case, you need to format your data as Excel Table first.
1. Press Ctrl + T, or go to the Home tab -> Format as Table and pick the style that suites you
best.
You will see the Create Table dialog box that you can use to highlight the necessary range.
2. Now that your list is formatted, select the range with the values or rows you want to delete
within your table.
Note. Please make sure you don't use the row buttons to select the entire rows.
3. Press Ctrl + - (minus on main keyboard) to see the unwanted data removed only from your
table. The additional information to the right will be left intact.
Hope you've found this "remove row" shortcut helpful. Continue reading to find Excel VBA for
deleting rows and learn how to eliminate data based on certain cell text.
Delete rows that contain certain text in a single column
If the items in the rows you want to remove appear only in one column, the following steps will
guide you through the process of deleting the rows with such values.
1. First you need to apply Filter to your table. To do this, navigate to the Data tab in Excel and
click on the Filter icon.
2. Filter the column that contains the values for deleting by the needed text. Click on the arrow
icon next to the column that contains the needed items. Then uncheck the Select All option and
tick the checkboxes next to the correct values. If the list is long, just enter the necessary text in
theSearch field. Then click OK to confirm.
3. Select the filtered cells in the rows you want to delete. It's not necessary to select entire rows.
4. Right-click on the highlighted range and and pick the Delete row option from the menu list.
Finally click on the Filter icon again to clear it and see that the rows with the values disappeared
from your table.
How to remove rows in Excel by cell color
The filter option allows sorting your data based on the color of cells. You can use it to delete all
rows that contain certain background color.
1. Apply Filter to your table. Go to the Data tab in Excel and click on the Filter icon.
2. Click on the small arrow next to the needed column name, go to Filter by Color and pick the
correct cell color. Click OK and see all highlighted cells on top.
3. Select the filtered colored cells, right-click on them and pick the Delete Row option from the
menu.
That's it! The rows with identically colored cells are removed in an instant.
Delete rows that contain certain text in different columns
If the values you want to remove are scattered around different columns, sorting may
complicate the task. Below you'll find a helpful tip to remove rows based on the cells that
contain certain values or text. From my table below, I want to remove all rows that contain
January which appears in 2 columns.
1. Start by searching and selecting the cells with the needed value using the Find and
Replacedialog. Click Ctrl + F to run it.
Tip. You can find the same dialog box if you go to the Home tab -> Find & Select and pick
theFind option from the drop-down list.
2. Enter the needed value in the Find what field and select any additional options if necessary.
Then press Find All to see the result.
Select the found values in the window keeping the Ctrl key pressed. You will get the found
values automatically highlighted in your table.
4. Now navigate to the Home tab -> Delete -> Delete Sheet Rows.
Tip. You can delete the rows with the selected values if you press Ctrl + - (minus on the main
board) and select the radio button Entire rows.
Voila! The unwanted rows are deleted.
Sub RemoveEveryOtherRow()
Dim rowNo, rowStart, rowFinish, rowStep As Long
Dim rng2Delete As Range
rowStep = 2
rowStart = Application.Selection.Cells(1, 1).Row
rowFinish = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For rowNo = rowStart To rowFinish Step rowStep
If Not rng2Delete Is Nothing Then
Set rng2Delete = Application.Union(rng2Delete, _
ActiveSheet.Cells(rowNo, 1))
Else
Set rng2Delete = ActiveSheet.Cells(rowNo, 1)
End If
Next
If Not rng2Delete Is Nothing Then
rng2Delete.EntireRow.Delete
' Hide every other row
'rng2Delete.EntireRow.Hidden = True
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Tip. If your task is to color every second/third, etc., row with a different color, you will find the
steps in Alternating row color and column shading in Excel (banded rows and columns).
In this article I described how to delete rows in Excel. Now you have several useful VBA macros
to delete the selected rows, you know how to remove every other row and how to use Find &
Replace to help you search and select all the lines with the same values before eliminating
them. Hope the tips above will simplify your work in Excel and let you get more free time for
enjoying these last summer days. Be happy and excel in Excel!
To be able to perform a case-sensitive vlookup in Excel, you need to add a helper column and
populate it with the below formula (where B is your lookup column):
=CODE(MID(B2,1,1)) & CODE(MID(B2,2,1)) & CODE(MID(B2,3,1)) &
CODE(MID(B2,4,1)) & CODE(MID(B2,5,1)) & CODE(MID(B2,6,1)) &
CODE(MID(B2,7,1)) & CODE(MID(B2,8,1)) & IFERROR(CODE(MID(B2,9,1)),"")
The formula parses the lookup value into individual characters, converts each char to its code
(e.g. "A" is 65 and "a" is 97), and then concatenates these codes into a unique number string.
After that, you use a simple Vlookup formula that matches case:
=VLOOKUP($G$3,$A$2:$C$8,3,FALSE)
The following two things are essential for the correct work of your Vlookup case-sensitive
formula:
1. The helper column should be the left-most column in the lookup range (table_array
argument).
2. The lookup value (lookup_value argument) shall be a "character code" rather than a real
value.
How to use the CODE formula correctly
The CODE formula that is copied across the helper column implies that all of your lookup values
have the same number of characters. If not, you need to know the min and max numbers and
add as many IFERROR functions as many chars make the difference between the smallest and
largest lookup values.
For example, if the smallest lookup value has 3 chars and largest - 5 chars, you use this
formula:
=CODE(MID(B2,1,1)) & CODE(MID(B2,2,1)) & CODE(MID(B2,3,1)) &
IFERROR(CODE(MID(B2,3,1)),"") & IFERROR(CODE(MID(B2,4,1)),"")
In the MID function, you specify the following arguments:
1st parameter (text) - this is text or a cell reference containing the characters you want to
extract (B2 in our case).
2nd parameter (start_num) - the position of the first character you want to extract. You
enter 1 in the first MID function, 2 in the second and so on.
3rd parameter (num_chars) - specifies the number of characters you want to return from
text. Since you always want just 1, you enter "1" in all the functions.
VLOOKUP limitations: The VLOOKUP function is not the best way to do a case-sensitive
lookup in Excel because, firstly, it requires adding a helper column, and secondly, it works better
on homogeneous data sets, or at least when you know the exact number of symbols in your
lookup values. If this is not your case, please try out other solutions that follow below.
LOOKUP formula for case-sensitive match
Excel's LOOKUP function is very akin to VLOOKUP, however its syntax lets you match a case
without adding a helper column. To do this, you have to use LOOKUP together with the EXACT
function.
If we take the data from the previous example (without the helper column A with codes), the
following Lookup / Exact formula will work a treat:
=LOOKUP(TRUE,EXACT($A$2:$A$7,$F$2),$B$2:$B$7)
The formula searches through cells A2:A7 for the exact case-sensitive value in cell F2 and
returns a value from column B in the same row.
As well as VLOOKUP, the LOOKUP functions works for numerical and text values equally well,
and the below screenshot is a good evidence:
Important! For the LOOKUP formula to work correctly, the values in your lookup column must
be sorted in ascending order, i.e. from smallest to largest.
Let me briefly explain the use of the EXACT function in the above formula because this is the
key point.
Excel's EXACT function compares two text values in the 1st and 2nd arguments and returns
TRUE if they are exactly the same, FALSE otherwise. What is really important for us is that
EXACT is case-sensitive.
Now, let's analyze how our LOOKUP / EXACT formula
works: =LOOKUP(TRUE,EXACT($A$2:$A$7,$F$2),$B$2:$B$7)
The EXACT function checks the value of cell F2 against all the items in column A
(A2:A7) and if an exact case-sensitive match is found, returns TRUE, otherwise - FALSE.
Since you've entered TRUE in the first parameter (lookup_value) of the LOOKUP
function, it pulls a corresponding value from the return column (column B in this example), only
when the exactcase-sensitive match is found.
Hopefully, the above explanation makes sense and you understand the general idea now. If you
do, you won't have any difficulties with other functions that we are going to explore next, since
all of them are based on the same principle.
LOOKUP limitations: requires sorting the lookup column in ascending order.
SUMPRODUCT - look up case of text values and return matching numbers
As you've already understood from the heading, SUMPRODUCT is yet another Excel function
can do a case-sensitive lookup, but can return numeric values only. If this is not your case,
you can skip directly to INDEX MATCH that provides a general solution and works on all data
types.
First off, let me briefly explain the syntax of this function, it will help you better understand the
case-sensitive SUMPRODUCT formula that follows below.
Excel's SUMPRODUCT multiplies components in the specified arrays, and returns the sum of
the products. Its syntax is as follows:
SUMPRODUCT(array1,array2,array3, ...)
Since we want a case sensitive lookup, we use the EXACT function from the previous
example as one of the multipliers:
=SUMPRODUCT((EXACT($A$2:$A$7,$F$2)*($B$2:$B$7)))
As you remember, the EXACT function compares the value in cell F2 against all the items in
column A and if an exact case-sensitive match is found, returns TRUE, otherwise FALSE . In
mathematical operations, Excel treats TRUE as "1" and FALSE as "0", so the SUMPRODUCT
function multiplies the returned numbers and sums the products.
Zeros do not count, because a zero always produces "0" whatever number it is multiplied by.
So, let's have a closer look at what happens when an exact match is found in column A and "1"
is returned. The SUMPRODUCT function multiplies 1 by a number in column B in the same row
and returns exactly this number! This is because the products of other multiplications are zeros,
which do not impact the returned value in any way.
Regrettably, the SUMPRODUCT function cannot cope with text values and dates since they
cannot be multiplied. In this case, you will get the #VALUE! error message like in cell F4 in the
screenshot below:
This example comes last of all not only because the best is saved for the last, but also because
the knowledge you've gained from the previous examples may help you understand the casesensitive MATCH / INDEX formula better.
As you probably know, the combination of INDEX and MATCH functions is used in Excel as a
more flexible and powerful alternative to VLOOKUP. The following article does a good job
(hopefully : ) explaining how these two functions work together - Using INDEX / MATCH instead
of VLOOKUP.
I will just remind you the key points:
The MATCH function searches for a lookup value in a specified range and returns the
relative position of the value, i.e. row or/and column numbers.
From there, the INDEX function take those numbers and returns a value from the
specified column or row, or at the intersection of the column and row if both are supplied.
For INDEX / MATCH to be able to look up a case, you just need to add one more function to the
liaison. As you can easily guess, you need the EXACT function again:
=INDEX($B$2:$B$7,MATCH(TRUE,EXACT($A$2:$A$7,$F$2),0))
In the above formula, the EXACT function works in the same manner as in the LOOKUP
formulaand produces the same result:
Note. Please pay attention that the INDEX / MATCH formula is enclosed in curly braces,
meaning this is an array formula and you have to press Ctrl + Shift + Enter to complete it.
Why INDEX / MATCH is the best solution for case-sensitive vlookup
The main advantages of using INDEX / MATCH are:
1.
2.
3.
It does not require adding a helper column like the VLOOKUP function does.
It does not require sorting a lookup column like the LOOKUP function does.
It works with all data types - numbers, text and dates.
The above mentioned case-sensitive INDEX / MATCH formula seems perfect, right? But, in fact,
it is not. Let me show you why.
Suppose, a cell in the return column corresponding to a lookup value is blank. What shall the
formula return? Nothing. And now, let's see what it actually returns:
Oops, the formula returns a zero! Maybe, this is no big deal if you are working solely with text
values. However, if your worksheet contains numbers and some of them are real zeros, this is a
problem.
In truth, all other lookup formulas (VLOOKUP, LOOKUP and SUMPRODUCT) we have
discussed earlier behave in the same way. But now you want an impeccable formula, don't you?
To make the case-sensitive INDEX / MATCH formula absolutely perfect, you need to wrap it in
the IF function that will check whether a return cell is blank and return nothing in this case:
=IF(INDIRECT("B"&(1+MATCH(TRUE,EXACT($A$2:$A$7,$G$2),0)))<>"",INDEX($B
$2:$B$7,MATCH(TRUE,EXACT($A$2:$A$7,$G$2),0)),"")
In the above formula:
The INDEX / MATCH formula returns nothing if the return cell in empty:
If you want the INDEX / MATCH formula to display some message when a return value is blank,
you can write something between the last quotes ("") in the formula, like this:
=IF(INDIRECT("D"&(1+MATCH(TRUE,EXACT($B$2:$B$7,$G$2),0)))<>"",INDEX($D
$2:$D$7,MATCH(TRUE,EXACT($B$2:$B$7,$G$2),0))," There is nothing to
return, sorry.")
If you want to try out any of the above formulas on your data, feel free to download our casesensitive vlookup examples.
o
o
o
o
o
array - this is a range of cells that you want to return a value from.
row_num - the row number in array from which you want to return a value. If omitted,
the column_num is required.
column_num - the column number in array from which you want to return a value. If
omitted, row_num is required.
If both row_num and column_num parameters are used, the INDEX function returns the value in
the cell at the intersection of the specified row and column.
And here is the simplest example of the INDEX formula:
=INDEX(A1:C10,2,3)
The formula searches in cells A1 through C10 and returns a value of the cell in the 2nd row and
the 3rd column, i.e. cell C2.
Very easy, right? However, when working with real data you would hardly ever know which row
and column you want, that is why you need the help of the MATCH function.
The MATCH function's syntax and usage
The Excel MATCH function searches for a lookup value in a range of cells, and returns
the relative position of that value in the range.
For example, if the range B1:B3 contains the values "New-York", "Paris", "London", then the
formula =MATCH("London",B1:B3,0) returns the number 3, because "London" is the third entry
in the range.
The syntax of the MATCH function is as follows:
0 - finds the first value that is exactly equal to the lookup value. In the INDEX /
MATCH combination, you almost always need the exact match, so the third argument of your
MATCH function is "0".
-1 - finds the smallest value that is greater than or equal to lookup_value. The
values in the lookup array must be sorted in descending order, i.e. from largest to smallest.
At first sight, the usefulness of the MATCH function may seem questionable. Who cares about
the position of a value in a range? What we do want to know is the value itself.
Let me remind you that the relative position of the lookup value (i.e. a row or/and column
number) is exactly what you need to supply to the row_num or/and column_num argument of
the INDEX function. As you remember, the INDEX function can return the value at the juncture
of a given row and column, but it cannot determine which exactly row and column you want.
How to use INDEX MATCH function in Excel
Now that you know the basics of these two functions, I believe it has already started making
sense how Excel's MATCH and INDEX work together.
The MATCH function determines the relative position of the lookup value in the specified range
of cells. From there, the INDEX function takes that number, or numbers, and returns a value in
the corresponding cell.
Still having difficulties to figure it out? Think about Excel INDEX / MATCH in this way:
=INDEX (column to return a value from, (MATCH (lookup value, column to
lookup against, 0))
I believe it's even easier to understand from an example. Suppose you have a list of national
capitals like this:
Let's find the population of some capital, say the capital of Japan, using the following Index
Match formula:
=INDEX($D$2:$D$10,MATCH("Japan",$B$2:$B$10,0))
Now, let's analyze what each component of this formula actually does:
The MATCH function searches for the lookup value "Japan" in column B, more precisely
cells B2:B10, and returns the number 3, because "Japan" is the third in the list.
The INDEX functions takes "3" in the second parameter (row_num), which indicates
which row you want to return a value from, and turns into a simple =INDEX($D$2:$D$10,3).
Translated into plain English, the formula reads: search in cells D2 through D10 and return a
value of the cell in the 3rd row, i.e. cell D4, because we start counting from the second row.
And here's the result you get in Excel:
Important! The number of rows and columns in the INDEX array should match those in the
row_num or/and column_num parameters of the MATCH functions, respectively. Otherwise, the
formula will return incorrect result.
Wait, wait... why don't we simply use the following Vlookup formula? What's the point in wasting
time trying to figure out the arcane twists of Excel's MATCH / INDEX?
=VLOOKUP("Japan",$B$2:$D$2,3)
In this case, no point at all : ) This simple example is for demonstration purposes only, so that
you get a feel of how the Index and Match functions work together. Other examples that follow
below will show you the real power of the INDEX MATCH liaison that easily copes with many
complex scenarios when VLOOKUP stumbles.
Why Excel's INDEX MATCH is better than VLOOKUP
When deciding which formula to use for vertical lookups, the majority of Excel gurus agree that
INDEX / MATCH is far better than VLOOKUP. However, many Excel users still resort to utilizing
VLOOKUP because it's a simpler function. This happens because very few people fully
understand all the benefits of switching from Vlookup to Index Match, and without such
understanding no one is willing to invest their time to learn a more complex formula.
Below, I will try to point out the key advantages of using MATCH / INDEX in Excel, and then you
decide whether you'd rather stick with Vlookup or switch to Index Match.
4 top benefits of using MATCH INDEX in Excel
1. Right to left lookup. As any educated user knows, Excel VLOOKUP cannot look to its left,
meaning that your lookup value should always reside in the left-most column of the lookup
range. With INDEX MATCH, your lookup column can be on the right side of your table as well.
The following example demonstrates this feature in action - How to lookup values to left.
2. Insert or delete columns safely. VLOOKUP formulas get broken or return incorrect results
when a new column is deleted from or added to a lookup table. With VLOOKUP, any inserted or
deleted column changes the results returned by your formulas because the VLOOKUP
function's syntax requires specifying the entire table array and a certain number indicating which
column you want to pull the data from.
For example, if you have a table A1:C10 and want to return a value from column B, you will put
"2" in the third parameter (col_index_num) of a VLOOKUP formula, say = VLOOKUP("lookup
value", A1:C10, 2). If at a later point, you insert a new column between A and B, you will have to
change "2" to "3" in your formula, otherwise it would return a value from the newly inserted
column.
With INDEX MATCH, you can delete or insert new columns in your lookup table without
distorting the results since you specify directly the column containing the value you want to get.
And this is a really great benefit, especially when working with large datasets, since you are
able to insert and remove columns without worrying about updating every associated vlookup
formula.
3. No limit for a lookup value's size. When using the VLOOKUP function, remember that the
total length of your lookup criteria should not exceed 255 characters, otherwise you will end up
having the #VALUE! error. So, if your dataset contains long strings, INDEX MATCH is the only
working solution.
Suppose, you are using the following VLOOKUP formula that searches through cells B5 to D10
for the value in cell A2:
=VLOOKUP(A2,B5:D10,3,FALSE)
The formula won't work if the lookup value in cell A2 exceeds 255 symbols. Instead, you shall
use the analogous INDEX / MATCH function:
=INDEX(D5:D10, MATCH(TRUE, INDEX(B5:B10=A2, 0), 0))
4. Higher processing speed. If you are working with relatively small tables, the difference in
Excel's performance will most likely be unnoticeable, especially in recent versions. But if you
use large worksheets with thousands of rows and thousands of lookup formulas, Excel will work
much faster if you use MATCH INDEX rather than VLOOKUP. Generally, the use of Index /
Match formulas increases Excel's performance by 13% compared to equivalent Vlookup
formulas.
VLOOKUP's impact on Excel's performance may be especially evident if your workbook
contains hundreds of complex array formulas like VLOOKUP and SUM. The point is that
checking each value in the array requires a separate call of the VLOOKUP function. So, the
more values your array contains and the more array formulas you have in a workbook, the
slower Excel performs.
On the other hand, with INDEX MATCH, Excel has to consider only the lookup and return
columns, as the result it processes such formulas much faster.
Excel INDEX & MATCH - formula examples
Now that you know the reasons to learn the MATCH INDEX function, let's get to the most
interesting part and see how you can apply the theoretical knowledge in practice.
How to lookup values to left with INDEX & MATCH
As stated in any VLOOKUP tutorial, this Excel function cannot look at its left. So, unless your
lookup column is the left-most column in the lookup range, there's no chance that a vlookup
formula will return the result you want.
Excel's INDEX MATCH function is more flexible and does not really care where the return
column resides. As an example, we will use the table listing national capitals by population
again. This time, let's write an INDEX MATCH formula that finds how the Russian capital,
Moscow, ranks in terms of population.
As you can see in the screenshot below, the following formula works perfectly:
=INDEX($A$2:$A$10,MATCH("Russia",$B$2:$B$10,0))
By now, you should not have any difficulties to understand how the formula works:
First, you write a simple MATCH formula that finds the position of Russia:
=MATCH("Russia",$B$2:$B$10,0))
Then, you determine the array parameter for your Index function, which is column A in
our case (A2:A10).
Finally, you assemble the two parts together and get this formula:
=INDEX($A$2:$A$10,MATCH("Russia",$B$2:$B$10,0))
Tip. It's a good idea to always use absolute cell references in INDEX and MATCH formulas so
that your lookup ranges won't get distorted when you copy the formula to other cells.
Download Lookup to left example.
Calculations with INDEX MATCH in Excel (AVERAGE, MAX, MIN)
You can nest other Excel functions within the MATCH INDEX formula, say, to find the minimum
or maximum value, or the value closest to the average in the range. Here are a few formula
examples for the table used in the previous sample:
Function
Formula example
Description
Returned
result
Min
=INDEX($C$2:$C$10,
MATCH(MIN($D$2:I$10),
$D$2:D$10, 0))
Beijing
=INDEX($C$2:$C$10,
MATCH(MAX($D$2:I$10),
$D$2:D$10, 0))
Max
Lima
same row.
Average
=INDEX($C$2:$C$10,
MATCH(AVERAGE($D$2:D$10),
$D$2:D$10, 1))
Moscow
If you are curious to know analogues VLOOKUP formulas, here you go: Calculations with
VLOOKUP (AVERAGE, MAX, MIN).
Okay, let's start on the formula. Whenever I need to create a complex Excel formula with one or
several nested functions, I always write each individual function first.
So, you start by writing two MATCH functions that will return the row and column numbers for
your INDEX function.
Vertical match - you search through column B, more precisely in cells B2 to B11, for the
value in cell H2 ("USA"), and the corresponding MATCH function is
And finally, since we need to check each cell in the array until the formula finds a result, this
INDEX MATCH formula should be an array formula. You can determine this by curly braces in
which it is encapsulated. So, remember to press Ctrl + Shift + Enter to complete the formula
after you've finished typing.
If everything is done correctly, you will get a result similar to what you see in the screenshot
below:
=IFERROR(INDEX($A$1:$E$11, MATCH($G$2,$B$1:$B$11,0),
MATCH($G$3,$A$1:$E$1,0)),
"No match is found. Please try again!")
And now, if someone inputs an invalid entry, the formula will produce the result you see in the
screenshot below:
If you prefer to have a blank cell when an error is returned, you can just use double quotes ("")
in IFERROR's second parameter, like this:
IFERROR(INDEX(array, MATCH(lookup_value, lookup_array, 0), "")
Download INDEX / MATCH with IFERROR example.
I hope at least one formula described in this tutorial proved to be helpful for you. If you are faced
with some other lookup task for which you have not found a solution here, don't hesitate to drop
me a comment and we will try to fathom it out.
Absolute cell references (with the $ sign, e.g. $A$1) always remain constant, no matter
where they are copied.
Relative cells references (without the $ sign, e.g. A1) change based on the relative
position of rows and columns, when copied across multiple cells.
Mixed cells references (absolute column and relative row (e.g. $A1), or relative column
and absolute row (e.g. A$1). In Excel conditional formatting rules, mixed cell references are
used most often, indicating that a column letter or row number is to remain fixed when the rule is
applied to all other cells in the selected range.
In conditional formatting rules, cell references are relative to the top-left most cell in the
applied range. So, when making a new rule, you can simply pretend as if you are writing a
formula for the top-left cell only, and Excel will "copy" your formula to all other cells in the
selected range.
Now, let me show you a few examples that demonstrate how seemingly identical formulas
produce different results depending on what cell references types are used.
Example 1. Absolute column and relative row
This pattern is most typical for conditional formatting rules and in 90% of cases cell references
in your Excel conditional formatting rules will be of this type.
Let's make a very simple rule that compares values in columns A and B and highlights a value in
column A if it is greater than a value in column B in the same row.
If you need the detailed instructions on how to create conditional formatting rules with formulas,
here you go - Creating an Excel conditional formatting rule using a formula. In this case, the
formula is obvious:
=$A1>$B1
Because you always compare values in columns A and B, you "fix" these column by
usingabsolute column references, notice the $ sign before the column letters in the above
formula. And, since you are comparing the values in each row individually, you use relative row
references, without $.
Because you want the row numbers to be fixed, you use the absolute row references, with the
$ sign. And, because you want to compare values in each column individually, you create the
rule for the left-most column (A) and use relative column references, without the $ sign.
Example 3. Absolute column and absolute row
You use absolute row and absolute column references if you want to compare all values in the
selected range with some other value.
For example, let's create a rule that highlights all values in column A that are greater than a
value in cell B1. The formula is as follows:
=$A1>$B$1
Please pay attention to the use of the following references:
$A1 - you use an absolute column and relative row references because we want to
check values in all cells of column A against the value in cell B1.
$B$1 - you use absolute column & absolute row because cell B1 contains the value
you want to compare all other values against and you want this cell reference to be constant.
similar to this:
Hopefully, these simples examples have helped you fathom out the essence of relative and
absolute cell references in Excel. Now that you know how to determine the appropriate
reference type for your rules, go ahead and harvest the power of Excel conditional formatting for
your projects. The following resources may prove helpful:
Excel formulas for conditional formatting based on another cell - the tutorial provides a
handful of examples that demonstrate how to format individual cells or entire rows based on
another cell's value in Excel 2013, 2010 and 2007.
How to conditionally format dates in Excel - the article explains how you can apply Excel
conditional formatting to dates using built-in rules and formulas.
How to change the row color based on a cell's value - this article will teach you how to
highlight entire rows based on a numeric or text value of a single cell.
Alternate row colors and column shading in Excel - the tutorial explains how to alternate
every other row or column in Excel. You will also find the formula to alternate row colors based
on a value change.
Change background color based on cell value - two quick ways to change the
background color of cells based on their values.
How to automatically highlight duplicates in Excel - see how you can use Excel
conditional formatting to highlight duplicates values.
Conditional formatting in Excel PivotTables - this tutorial covers some of the differences
in PivotTable formatting in Excel 2010.
You want to compare 2 or 3 columns but they are separated by several other columns.
For example, you need to see column A and column Y side-by-side. You may also find the
articleHow to freeze panes helpful.
You have several helper columns with calculations or formulas that may confuse other
users of the workbook.
You would like to keep some important formulas or personal details from being seen or
edited by your colleagues. You can learn how to protect your columns from being displayed if
you have a look at Disable the Unhide column option in Excel.
Read on to see how Excel enables you to hide columns in an instant. In this article you'll also
find an interesting way to hide columns via the Group option which adds special icons to quickly
conceal and display certain columns.
2. Right-click above one of the selected columns and pick the Hide option from the menu list.
Tip. The shortcut-oriented users will appreciate this hotkey for hiding the selected
columns: Ctrl+0.
Voila! Now you can easily review your data skipping the extra details.
3. You will see the Group dialog box appear. Select the Columns radio button and click OK to
confirm.
Tip. You can get the same dialog if you go to Data -> Group -> Group.
Tip. You can select the range and press Shift + Alt + left arrow to remove grouping.
This will add special Outline symbols to your table.
4. Now select the columns you want to hide one by one and press Shift + Alt + right arrow for
each column.
Note. It's not possible to select several non-adjacent columns.
As soon as you press the hotkey, you will see the minus sign icon added to the outline above
your selected columns.
5. Clicking on the minus icon will hide the column and the icon will change to the plus sign
letting you to instantly unhide the data.
6. You can also use the small numbers in the top left corner. They let you hide and unhide all
groupings of the same level at once. For example, in my table on the screenshot, clicking on 1
will hide the entire table and clicking 2 will hide columns C and E. This is especially useful if you
created a hierarchy of grouping.
That's it. You learnt how to use the Excel Hide columns option. You also know how to group and
ungroup columns to show or hide them. Hope you found the tips helpful and they will simplify
your daily work with tables. Be happy and excel in Excel!
Now, you want to make a summary table with the total sales for each product.
The solution is to use an array in the 3rd parameter (col_index_num) of the Excel VLOOKUP
function. Here is a sample VLOOKUP formula:
=SUM(VLOOKUP(lookup value, lookup range, {2,3,4}, FALSE))
As you see, we use an array {2,3,4} in the third argument to perform several lookups within the
same VLOOKUP formula in order to get the sum of values in columns 2,3 and 4.
And now, let's adjust this combination of VLOOKUP and SUM functions for our data to find the
total of sales in columns B - M in the above table:
=SUM(VLOOKUP(B2, 'Monthly sales'! $A$2:$M$9,
{2,3,4,5,6,7,8,9,10,11,12,13}, FALSE))
Important! Since you are building an array formula, be sure to hit Ctrl + Shift + Enter instead of
a simple Enter keystroke when you finished typing. When you do this, Microsoft Excel encloses
your formula in curly braces like this:
{=SUM(VLOOKUP(B2, 'Monthly sales'!$A$2:$M$9,
{2,3,4,5,6,7,8,9,10,11,12,13}, FALSE))}
If you press the Enter key as usual, only the first value in the array will get processed, which will
produce incorrect results.
Tip. You may be curious why the formula displays [@Product] as the lookup value in the
screenshot above. This is because I converted my data to table (Insert tab > Table). I find it very
convenient to work with fully-functional Excel tables rather than mere ranges. For example,
when you type a formula into one cell, Excel automatically copies it across the entire column
and in this way saves you a few precious seconds :)
As you see, using the VLOOKUP and SUM functions in Excel is easy. However, this is not the
ideal solution, especially if you are working with big tables. The point is that using array formulas
may adversely affect the workbook's performance since each value in the array makes a
separate call of the VLOOKUP function. So, the more values you have in the array and the
more array formulas you have in your workbook, the slower Excel works.
You can bypass this problem by using a combination of the INDEX and MATCH functions
instead of SUM and VLOOKUP, and I will show you a few formula examples in the next article.
Download this VLOOKUP and SUM sample.
How to perform other calculations with Excel VLOOKUP function
A moment ago we discussed an example of how you can extract values from several columns in
the lookup table and calculate the sum of those values. In the same fashion, you can perform
other mathematical calculations with the results returned by the VLOOKUP function. Here are a
few formula examples:
Operatio
n
Formula example
Description
Calculate
average
{=AVERAGE(VLOOKUP(A2,
'Lookup Table'$A$2:$D$10,
{2,3,4}, FALSE))}
Find
maximum
value
{=MAX(VLOOKUP(A2, 'Lookup
Table'$A$2:$D$10, {2,3,4},
FALSE))}
Find
minimum
value
{=MIN(VLOOKUP(A2, 'Lookup
Table'$A$2:$D$10, {2,3,4},
FALSE))}
Calculate
% of sum
{=0.3*SUM(VLOOKUP(A2,
'Lookup Table'$A$2:$D$10,
{2,3,4}, FALSE))}
Note. Since all of the above formulas are array formulas, remember to press Ctrl+Shift+Enter to
enter them correctly in a cell.
If we add the above formulas to the 'Summary Sales' table from the previous example, the result
will look similar to this:
to make a formula that finds the total of all orders made by a given customer.
As you remember, you cannot utilize the Excel VLOOKUP function since you have multiple
instances of the lookup value (array of data). Instead, you use a combination of SUM and
LOOKUP functions like this:
=SUM(LOOKUP($C$2:$C$10,'Lookup table'!$A$2:$A$16,'Lookup table'!
$B$2:$B$16)*$D$2:$D$10*($B$2:$B$10=$G$1))
Since this is an array formula, remember to press Ctrl + Shift + Enter to complete it.
And now, let's analyses the formula's ingredients so that you understand how each of the
functions works and can to tweak it for your own data.
We'll put aside the SUM function for a while, because its purpose is obvious, and focus on the 3
components that are multiplied:
1. LOOKUP($C$2:$C$10,'Lookup table'!$A$2:$A$16,'Lookup table'!
$B$2:$B$16)
This LOOKUP function looks up the goods listed in column C in the main table, and returns the
corresponding price from column B in the lookup table.
2. $D$2:$D$10
This component returns quantity of each product purchased by each customer, which is listed in
column D in the main table. Multiplied by the price, which is returned by the LOOKUP function
above, it gives you the cost of each purchased product.
3. $B$2:$B$10=$G$1
This formula compares the customers' names in column B with the name in cell G1. If a match
is found, it returns "1", otherwise "0". You use it simply to "cut off" customers' names other than
the name in cell G1, since all of us know that any number multiplied by zero is zero.
Because our formula is an array formula it iterates the process described above for each value
in the lookup array. And finally, the SUM function sums the products of all multiplications.
Nothing difficult at all, it is?
Note. For the LOOKUP formula to work correctly you need to sort the lookup column in your
Lookup table in ascending order (from A to Z). If sorting is not acceptable on your data, check
out an awesome SUM / TRANSPOSE formula suggested by Leo.
Download this LOOKUP and SUM sample.
VLOOKUP and SUMIF - look up & sum values that meet certain criteria
Excel's SUMIF function is similar to SUM we've just discussed in the way that it also sums
values. The difference is that the SUMIF function sums only those values that meet the criteria
you specify. For example, the simplest SUMIF formula =SUMIF(A2:A10,">10") adds the
values in cells A2 to A10 that are larger than 10.
This is very easy, right? And now let's consider a bit more complex scenario. Suppose you have
a table that lists the sales persons' names and ID numbers (lookup table). You have another
table that contains the same IDs and associated sales figures (main table). Your task is to find
the total of sales made by a given person by their ID. At that, there are 2 complicating factors:
The mail table contains multiple entries for the same ID in a random order.
You cannot add the "Sales person names" column to the main table.
And now, let's make a formula that, firstly, finds all sales made by a given person, and secondly,
sums the found values.
Before we start on the formula, let me remind you the syntax of the SUMIF function:
3. Sum range - this is the easiest part. Since our sales numbers are in column C named
"Sales", we simply put Main_table[Sales].
Now, all you need is to assemble the formula's parts and your SUMIF + VLOOKUP formula is
ready:
=SUMIF(Main_table[ID],VLOOKUP($F$2,Lookup_table,2,FALSE),Main_table[Sa
les])
Instead of figuring out formulas, you simply specify your main and lookup tables, define a
common column or columns, and tell the wizard what data you want to fetch.
Then you allow the wizard a few seconds to look up, match and deliver you the results. If you
think this add-in may prove helpful in your work, you are most welcome to download a trial
version : )
Advanced VLOOKUP formula examples: nested vlookup with multiple criteria, two-way
lookup
In this second part of our Excel VLOOKUP tutorial, we will explore a few examples that will help
you harness the power of VLOOKUP to cope with the most challenging Excel tasks. The
samples imply that you know the basics of how this Excel function works. If not, you might want
to start with Part 1 that explains VLOOKUP syntax and general usages.
Well, let's have a closer look at the following VLOOKUP formula examples:
A usual VLOOKUP formula won't do in this scenario, because it returns the first found value
matching the lookup value you specify. So, if you want to know the quantity of "Sweets" ordered
Note. For the formula to work, the left-most column of your lookup table must contain the look
up values concatenated exactly as in your lookup criteria. As you see in the screenshot above,
we concatenated values with a space in the lookup table, so we do the same in the lookup
criteria of the VLOOKUP formula (B2&" "&C2).
Also, please remember about Excel VLOOKUP's limit of 255 characters. The VLOOKUP
function cannot search for a lookup value containing more than 255 chars. So, keep this number
in mind and make sure the total length of your lookup criteria does not exceed this limit.
I agree that adding an additional column is not a very elegant solution and is not always
acceptable. You can actually do without the "helper column", but in this case you would need a
far more complex formula with a combination of INDEX and MATCH functions.
Download this sample (VLOOKUP with multiple criteria).
How to use VLOOKUP to get 2nd, 3rd, 4th, etc. matching values
As you already know, Excel VLOOKUP can fetch only one matching value, more precisely, the
first found item. But what if there are several matches in your lookup array and you want to get
the 2nd or 3rd occurrence? Moreover, what if you want to pull all matching values? The task
sounds quite intricate, but the solution does exist!
Suppose, you have customer names in one column and the products they purchased in another.
And now, you want to find the 2nd, 3rd, or 4th product purchased by a given customer.
The simplest way is to add a helper column before the Customer Names column and populate it
with the customer's name and occurrence number, e.g. "John Doe1", "John Doe2" etc. The
following COUNTIF formula does the trick (assuming that the customer names are in column B):
=B2&COUNTIF($B$2:B2,B2)
After that, you can use a usual VLOOKUP formula to find the corresponding order. For example:
Naturally, you can enter a cell reference instead of text in the lookup value, as you see in the
screenshot below:
If you are looking for the 2nd occurrence only, you can do without the helper column by creating
a more complex VLOOKUP formula:
=IFERROR(VLOOKUP($F$2,INDIRECT("$B$"&(MATCH($F$2,Table4[Customer
Name],0)+2)&":$C16"),2,FALSE),"")
In the formula:
$F$2 - the cell with the customer name (it is constant, please notice the absolute cell
references);
$B$ - the "Customer Names" column;
Table4 - your table (this can also be a usual range);
$C16 - the last cell of your table or a range.
Note. This formula finds the second matching value only. If you have to get other occurrences,
please proceed with the previous solution.
Download this sample (VLOOKUP to get 2nd, 3rd, 4th, etc. matching values).
If you want to get the list of all matching values, the VLOOKUP function cannot help, because it
can return only one value at a time, alas. But Excel's INDEX function can handle this scenario
and I will show you the formula in the next example.
How to get all duplicate values in the lookup range
As mentioned above, the Excel VLOOKUP function cannot get duplicate instances of the lookup
value. To do this, you would need a far more complex array formula consisting of several Excel
functions such as INDEX, SMALL and ROW.
For instance, the below formula finds all instances of the value in cell F2 in the lookup range
B2:B16, and returns values from column C in the same rows:
{=IFERROR(INDEX($C$2:$C$16, SMALL(IF($F$2=B2:B16, ROW(C2:C16)-1,""),
ROW()-3)),"")}
Copy the below formula to several adjacent cells, e.g. cells F4:F8 as demonstrated in the
screenshot below. The number of cells where you copy the formula should be equal to or larger
than the maximum number of possible duplicate entries. Also, remember to press Ctrl + Shift +
If you are curious to know the underlying logic, let's drill down into the formula a bit:
Part 1. IF($F$2=B2:B16,ROW(C2:C16)-1,"")
$F$2=B2:B16 - compares the value in cell F2 with each value in the range B2:B16. If a match
is found, ROW(C2:C16)-1 returns the number of the corresponding row (-1 is used to deduct
the header row). If the compared values do not match, the IF function returns an empty string.
The result of the IF function is the following array {1, "", 3, "", 5, "", "", "", "", "", "",12, "", "", ""}
Part 2. ROW()-3
In this case, the ROW function acts as an incremental counter. Since the formula is copied into
cells F4:F9, we add -3 for the function to return 1 for cell F4 (row 4 minus 3), 2 for cell F5 (row 5
minus 3), etc.
Part 3. SMALL(IF($F$2=$B$2:$B$16,ROW($C$2:$C$16)-1,""),ROW()-3))
The SMALL function returns the k-th smallest value in a data set. In our case, the position (from
the smallest) to return is defined by the ROW function (Part 2). So, for cell F4, the function
SMALL({array},1) returns the 1st (smallest) element of the array, i.e. 1. For cell F5, it returns the
2nd smallest element of the array, which is 3, and so on.
You can do two-way lookup in a few different ways. So, look through the possible alternatives
below and choose your winner : )
VLOOKUP & MATCH functions
You can use a liaison of the VLOOKUP and MATCH functions to cross-reference two fields in a
database, Product (row) and Month (column) in this example:
=VLOOKUP("Lemons",$A$2:$I$9,MATCH("Mar",$A$1:$I$1,0),FALSE)
The formula above is a usual Excel VLOOKUP function that searches for the exact match of
"Lemons" in cells A2 through I9. But, since you do not know in which exactly column March's
sales are, you cannot supply the column number in the third argument of your VLOOKUP
formula. Instead, you use the MATCH function to find that column.
3. In any empty cell, type =row_value column_value, e.g. =Lemons Mar, or vice versa =Mar
Lemons.
Please remember to separate your row value and column value with a space, which acts as
theintersection operator in this case.
As you type, Microsoft Excel will display a list of matching names, exactly as it does when you
start typing a formula.
To pull the prices from Lookup table 2 to the Main table, you have to perform what is known as
Excel's double vlookup, or nested vlookup.
1. Create a VLOOKUP formula that finds the product name in "Lookup table 1", using a new
SKU as the lookup value:
=VLOOKUP(A2,New_SKU,2,FALSE)
Where 'New_SKU' is a named range for $A:$B in "Lookup table 1", and "Lookup table 2", is
column B containing the products names (please see the image above).
2. Write the formula to pull the prices from "Lookup table 2", based on the product's name, by
nesting the above vlookup function in the lookup criteria:
=VLOOKUP(VLOOKUP(A2,New_SKU,2,FALSE),Price,3,FALSE)
Where 'Price' is a named range $A:$C in Lookup table 2, and 3 is column C containing the
prices.
The screenshot below shows the result returned by our nested vlookup formula:
Suppose, you have a few regional sales reports for the same products in the same format, and
you want to find the sales number for a certain region:
If you have just a couple of regional reports, you can use a fairly simple VLOOKUP formula with
anIF function to select the correct sheet for vlookup:
=VLOOKUP($D$2,IF($D3="FL",FL_Sales,CA_Sales),2,FALSE)
Where:
$D$2 is a cell containing the "Product Name". Note that we use absolute cell references
in this case to prevent the lookup value from changing when copying the formula to other cells.
$D3 is a cell with the state name (use an absolute column reference and relative row if
you plan to copy the formula to other cells in the same column).
FL_Sales and CA_Sales are the table names, or named ranges, for corresponding sales
reports. You can also use worksheets names and usual cell ranges, e.g. 'FL Sheet'!$A$3:$B$10,
but using named ranges is much more convenient.
However, if you have multiple lookup tables, the IF function is not the ideal solution. Instead, you
can use the INDIRECT function to return the required lookup range.
As you probably know, the Excel INDIRECT function is used to indirectly reference a cell, and
this is exactly what we need now. So, go ahead and replace the IF statement with the
INDIRECT reference in the above formula. The following combination of VLOOKUP and
INDIRECT works a treat in our case:
=VLOOKUP($D$2,INDIRECT($D3&"_Sales"),2,FALSE)
Where:
$D$2 is the cell containing the product name, it always remains constant due to the
absolute row and column references.
$D3 is the cell containing the first state name, FL in our case.
"_Sales" is the common part of your range names, or table names. Concatenated with
the value in cell D3 it makes the full name of the required range. Below I'll provide some more
details for those who do not have much experience with Excel's INDIRECT function.
INDIRECT & VLOOKUP - how it works
First off, let me remind you the syntax of the INDIRECT function: INDIRECT(ref_text, [a1])
The first parameter can be a cell reference of the A1-style or R1C1-style, a range name, or a
text string. The second parameter specifies what type of reference is contained in ref_text - A1style (TRUE or omitted) or R1C1-style (FALSE). It is A1 in our case, so we can omit the second
parameter and focus solely on the first one.
Now, let's get back to our sales reports. As you remember, each report is a separate table
residing in a separate sheet. For the formula to work, you need to name your tables or ranges,
and all of the names should have some common part. For example, my sales reports are
named: CA_Sales, FL_Sales, TX_Sales etc. As you see, there is always the _Sales part.
So, our INDIRECT function INDIRECT($D3&"_Sales") concatenates the value in column D and
the word _Sales (with an underscore), and tells the VLOOKUP function in which exactly table to
look up. That is, if you have FL in cell D3, the formula will search in the FL_Sales table, if CA - in
CA_Sales table, and so on.
The result produced by your VLOOKUP and INDIRECT functions will look similar to this:
If your data reside in different workbooks, you will have to add a workbook name before the
named region (WorkbookName!NamedRange), for example:
=VLOOKUP($D$2,INDIRECT($D3&"Workbook1!_Sales"),2,FALSE)
Note. If the INDIRECT function refers to another workbook, that workbook must be open. If the
source workbook is not open, your INDIRECT formula will return the #REF! error.
Download this sample (VLOOKUP and INDIRECT).
Merge Tables Wizard - a visual way to do vlookup in Excel
If you are not an avid fan of complex Excel formulas and you'd rather save our energies for
occupations more interesting than making your way through the arcane twists of lookup criteria
and arrays, you may find this merging tool really helpful.
Instead of writing formulas, the Merge Tables Wizard will ask you to supply your main table and
lookup table, specify a common column or columns, and point out what info you want to update
or add to the end of the main table.
Then you click Next and allow the Merge Tables Wizard a few seconds to look up, match and
deliver the result. If you think you may like this add-in, you are most welcome to download a trial
version : )
The first and the last columns in a typical waterfall chart represent total values. The intermediate
columns appear to float, and show positive or negative change from one period to another,
ending up in the final total value. As a rule, these columns are color-coded for distinguishing
positive and negative values. A bit further in this article you'll know a trick how to make the
intermediate columns float.
A waterfall chart is also known as an Excel bridge chart since the floating columns make a socalled bridge connecting the endpoints.
These charts are quite useful for analytical purposes. If you need to evaluate a company profit
or product earnings, make an inventory or sales analysis or just show how the number of your
Facebook friends changed during that year, a waterfall chart in Excel is just what you need.
position.
Excel bridge chart will be a perfect way to visualize the sales flow over twelve months. But if you
apply a Stacked Column chart template to these particular values now, you'll get nothing similar
to a waterfall chart. So the first thing you should do is carefully rearrange your data.
Step 1: Rearrange the data table
You start with inserting three additional columns in your Excel table. Let's call them Base, Fall
and Rise. The Base column will be a calculated amount that is used as a starting point for the
Fall and Rise series in the chart. All the negative numbers from the Sales Flow column will be
placed in theFall column and all the positive numbers will be in the Rise column.
I've also added the End row at the bottom of the Month list to calculate the sales amount for the
whole year. Now move to the next step and fill in these columns with the necessary values.
4. Use the fill handle to copy this formula down the column.
5. Insert the last formula =B4+D4-C5 in cell B5 and copy it down; include the End row.
This formula calculates base values that will prop up the rises and falls to the appropriate
height.
Step 3. Create a standard Stacked Column chart
Now your data are well-organized and you are ready to build the chart itself.
1. Select your data including the column and row headers, exclude the Sales Flow column.
2. Go to the Charts group on the INSERT tab.
3. Click on the Insert Column Chart icon and choose Stacked Column from the drop-down list.
The graph appears in the worksheet, but it hardly looks like a waterfall chart. Take the next step
and turn the stacked column graph into Excel bridge chart.
The Format Data Series pane immediately appears to the right of your worksheet in Excel 2013.
2. Click on the Fill & Line icon.
3. Select No fill in the Fill section and No line in the Border section.
When the blue columns become invisible, just delete Base from the chart legend to completely
hide all the traces of the Base series.
When you are done, the chart should look like the one below:
Note. Alternatively, you can change the color and outline of the columns in the chart by opening
the Format Data Series pane or choosing the Fill or Outline options in the right-click menu.
Then you can remove excess white spaces between the columns to make them stand closer to
one another:
4. Double-click on one of the chart columns to bring up the Format Data Series pane.
5. Change the Gap Width to something smaller, like 15%. Close the pane.
When you look at the waterfall chart above, some of the flying bricks seem to be of the same
size. However, when you refer to the data table, you'll see that the represented values are
different. For more accurate analysis I'd recommend to add data labels to the columns.
6. Select the series that you want to label.
7. Right-click and choose the Add Data Labels option from the context menu.
Repeat the process for the other series. You can also adjust the label position, the text font and
color to make the numbers more readable.
Note. If there is an apparent difference in column size and the specifics aren't important, you
can omit the data labels, but then you should add a Y-axis for better data interpretation.
When you are done with labeling the columns, just get rid of unnecessary elements such as
zero values and the legend. You can also change the default chart title to something more
descriptive. Please take a look at one of my previous blog posts how to add titles to Excel
charts.
My waterfall chart is ready! It looks completely different from the commonly used types of charts
and it is very readable, isn't it?
You can even create a waterfall chart online and receive it as an Excel file by email. It is
possible thanks to a great waterfall-chart online service. You just need to submit your data,
specify your email address and wait less than a minute while your chart is generated. Then
check your inbox. The waterfall chart is sent to you in an Excel file. You can then change the
title, labels, colors, etc. like in any other Excel chart. However, you cannot change the numeric
data. In this case you will have to create a chart again. You should also follow some rules of
submitting your data if you want your waterfall chart to look as expected.
The more complex chart you want to build, the more complex formulas you have to enter when
rearranging your data. And the chance of getting an error is increasing. In this situation the
Waterfall Chart Creator add-in for Microsoft Excel can help you save your time and effort. With
this add-in you can create, change and update multiple waterfall charts at a time. It allows you
to specify colors, solid or gradient fill, show values and position, and gives you many other
options. You can also customize the default settings and colors for new charts.
Now you've got a collection of waterfall charts in Excel. I hope it won't be a problem for you to
manually create your own version of a bridge graph. Otherwise, you can take advantage of
Excel waterfall chart add-ins.
If you are curious of other means of data visualization, the following articles may also be
interesting for you:
When you have completed your macro you need to stop it recording which you do by clicking '
Stop recording'. Next to see the VBA code that you have generated just click on the 'Visual
Basic' button.
Here the macro just asks Excel to select Cell A1, to write Acuity Training in it and then to select
Cell A2.
In the example below we are checking what is in cell A1, which we put Acuity Training into
earlier in the article with our macro.
The file will be opened as a trusted document and the security warning will disappear.
2. You'll see the yellow Security Warning area. Click Enable Content.
3. You will see 2 features: Enable All Content and Advanced Options. Select Enable All
Content to always make the document's active content available.
The current Excel file will become a trusted document and all macros will be enabled.
1. Go to File -> Options -> Trust Center and press the Trust Center Settings button.
Tip. You can also click on the Trust Center Settings link on the Security Warning.
2. You will see the Trust Center window. Select the Macro Settings option.
3. Select the radio button Enable all macros (not recommended, potentially dangerous code can
run).
From now on all macros will run without warning.
Please note that this setting makes your computer open to viruses. You should be sure you get
all workbooks with macros only from the trusted publishers.
Disable all macros without notification. Macros and security alerts regarding them get
turned off.
Disable all macros with notification. If you select this radio button, macros will be
disabled, but security alerts will appear if there are macros in a file. It lets you enable macros in
Excel depending on the source.
Disable all macros except digitally signed macros. In this case, macros are turned
off, security alerts appear and digitally signed by a trusted publisher macros run. If you have not
trusted the publisher, you are offered to enable the signed macro and trust the publisher.
Enable all macros (not recommended, potentially dangerous code can run). All
macros run without warning. Please note that this setting makes your computer open to viruses.
Trust access to the VBA project object model. This checkbox forbids or allows
programmatic access to the Visual Basic for Applications (VBA) object model from an
automation client. This security setting is for the code that computerizes an Office program and
manipulates VBA environment and object model. For automation clients to access the VBA
object model, the user running the code must grant access. You need to tick the check box to
give access.
1. In Excel navigate to the File tab -> Options -> Trust Center -> Trust Center Settings ->
Trusted Locations.
2. Click on the Add new location button to see the Microsoft Office Trusted Location dialog box.
Note. Before adding any location to trusted, make sure it's really safe since such location can
be attacked by hackers.
2. Click on the Save as type: arrow and select the Excel Macro-Enabled Workbook from the list
of types.
o
o
o
o
o
1.
Note. If the lookup value is smaller than the smallest value in the first column of your
lookup array, the VLOOKUP function returns the #N/A error.
2.
table_array - two or more columns of data.
Remember, the VLOOKUP function always searches for the lookup value in the first
column of table_array. Your table_array may contain various values such as text,
dates, numbers, or logical values. Values are case-insensitive, meaning that
uppercase and lowercase text are treated as identical.
So, our formula =VLOOKUP(40, A2:B15,2) will search for "40" in cells A2 to A15
because A is the first column of the table_array A2:B15. Hopefully, everything is clear
so far : )
3.
Note. If your col_index_num argument is less than 1, the VLOOKUP formula will
return the #VALUE! error. In case it is greater than the number of columns in
table_array, your function will return the #REF! error.
4.
range_lookup - determines whether you are looking for an exact match
(FALSE) or approximate match (TRUE or omitted). This final parameter is optional
but very important. Further on in this VLOOKUP tutorial, I will provide a few
examples explaining how to correctly make formulas for exact or approximate match.
Excel VLOOKUP examples
I hope the VLOOKUP function is starting to look a bit more familiar to you. Now let's
explore a few examples of using VLOOKUP formulas on real data.
How to do vlookup in Excel from another worksheet
In practice, VLOOKUP formulas are rarely used to find data in the same worksheet.
Most often you will have to look up and pull the matching data from a different sheet.
To do a vlookup from a different Excel sheet, you should enter the worksheet's name
and an exclamation mark in the table_array argument before the range of cells,
e.g. =VLOOKUP(40, Sheet2!A2:B15,2). The formula indicates that the lookup
range A2:B15 is located in Sheet2.
Of course, you don't have to type the sheet's name manually. Simply start typing the
formula and when it comes to the table_array argument, switch to the lookup worksheet
and select the range using a mouse.
The formula you see in the screenshot below searches for the text "Product 1" in
column A (the 1stcolumn of the lookup range A2:B9) in the Prices worksheet:
=VLOOKUP("Product 1",Prices!$A$2:$B$9,2,FALSE)
Please pay attention that you have to enclose a lookup text value in quotes (''") as you
usually do in Excel formulas.
Tip. It is a good idea to always use absolute cell references (with $) in the table_array
parameter of VLOOKUP formulas. In this case, the lookup range will remain constant
when you copy the formula to other cells.
How to do vlookup from a different workbook
To perform vlookup between two different Excel workbooks, you should supply the
workbook's name in square brackets before the worksheet's name.
For example, the below formula will look up value "40" in Sheet2 of
the Numbers.xlsx workbook:
=VLOOKUP(40,[Numbers.xlsx]Sheet2!A2:B15,2)
The easiest way to create an Excel VLOOKUP formula that refers to another workbook
is as follows:
1.
Open both workbooks. This step is not obligatory, but makes it easier to make the
formula because you won't have to type the workbook's name manually. In addition,
it will protect your formulas from accidental misprints.
2.
Start typing your VLOOKUP formula, and for the table_array argument, switch to
the other workbook and select the lookup range there.
In the formula you see in the screenshot below, the lookup workbook
is PriceList.xlsx and the lookup worksheet is Prices.
Once you close the workbook with your lookup table, your VLOOKUP formula will work
anyway, but it will display the full path for the lookup workbook, as shown below:
Note. If either a workbook name or worksheet name contains spaces, you should add
apostrophes around them: =VLOOKUP(40, '[Numbers.xlsx]Sheet2'!A2:B15,2)
How to use a named range or table in VLOOKUP formulas
If you are supposed to use the same lookup range in several VLOOKUP formulas, you
can created a named range for it and type its name directly in the formula instead of the
lookup region (table_array argument).
To create a named range, you simply select the cells and type any name in the Name
box, to the left of the Formula bar.
And now you can write the following VLOOKUP formula to get Product 1's price:
=VLOOKUP("Product 1",Products,2)
Most range names in Excel apply to the entire workbook, so you don't need to specify
the worksheet's name in the table_array argument, even if your lookup range is in a
different worksheet. If it is in another workbook, you have to put the workbook's name
before the named range, for example:
=VLOOKUP("Product 1",PriceList.xlsx!Products,2)
Such formulas are far more understandable, aren't they? Besides, using named ranges
can be a good alternative to absolute cell references. Since a named range doesn't
change when a formula is copied to other cells, you can be sure that your lookup range
will always remain correct.
If you have converted a range of cells into a fully-functional Excel table (Insert
tab > Table), then you can select the lookup range using a mouse, and Microsoft Excel
will automatically add the columns' names (or the table name in case you've selected
When you do not remember the exact text you are looking for.
When you want to find some word that is part of the cell's contents. Be aware
that the VLOOKUP function searches by the entire content of a cell, as if you selected
the option "Match entire cell content" in the standard Excel Find dialog.
When a lookup column contains extra leading or trailing spaces. If it is the case,
you may rack your brain trying to figure out why the normal formula does not work.
Example 1. Look up text starting or ending with certain characters
Suppose, you want to find a certain customer in the below database. You cannot
remember his surname, but you know it starts with "ack". So, the following VLOOKUP
formula will work a treat:
=VLOOKUP("ack*",$A$2:$C$11,1,FALSE)
Once you are sure you've found the correct name, you can use a similar VLOOKUP
formula to get the sum paid by that customer. You only have to change the
3rd parameter in the formula to the appropriate column number, column C (3) in our
case:
=VLOOKUP("ack*",$A$2:$C$11,3,FALSE)
Here a few more examples of VLOOKUP formulas with wildcard characters:
=VLOOKUP("*man",$A$2:$C$11,1,FALSE) - find the name ending with "man".
=VLOOKUP("ad*son",$A$2:$C$11,1,FALSE) - find the name starting with "ad" and
ending with "son".
=VLOOKUP("?????",$A$2:$C$11,1,FALSE) - find a 5-character last name.
Note. For a wildcard VLOOKUP formula to work correctly, you always have to add
FALSE as the last parameter. If your lookup range contains more than one entry that
meets the wildcard criteria, the first found value will be returned.
Example 2. Wildcard VLOOKUP formulas based on cell's value
And now let's discuss a bit more complex example of how to do a vlookup on the value
in some cell. Suppose, you have license keys in column A and license names in column
B. You also have part (a few characters) of some license key in cell C1 and you want to
find a matching License Name.
This can be done using a VLOOKUP formula like this:
=VLOOKUP("*"&C1&"*",$A$2:$B$12,2,FALSE)
This formula searches for the value in C1 through the specified range and returns a
corresponding value in column B. Please notice that we use an ampersand (&) before
and after a cell reference in the 1st parameter to concatenate a text string.
As you can see in the screenshot below, my VLOOKUP function returns "Jeremy Hill"
because his license key contains the group of chars stated in cell C1:
Also, please pay attention to the table_array argument in screenshot above. It contains
the table name ("Table7") instead of a range of cells, as we discussed in the example
above.
Using VLOOKUP formulas with exact or approximate match
And finally, let's have a closer look at the last argument you supply to the Excel
VLOOKUP function - range_lookup. As already mentioned at the beginning of this
tutorial, this parameter is highly important because you are likely to get different results
in the same formula depending on whether you enter TRUE or FALSE.
First off, let's see what Microsoft Excel actually means by "exact match" and
"approximate match".
If range_lookup is set to FALSE, the formula searches for exact match, i.e. for
the lookup value exactly as you've entered it in the first parameter (lookup_value ).If
there are two or more values in the first column of table_array that match the lookup
value, the 1st value found is returned. If an exact match is not found, the #N/A error is
returned.
For example, if you use the formula =VLOOKUP(4, A2:B15,2,FALSE), but your data
does not contain value 4 in cells A2 through A15, the formula will return #N/A.
Please note, our lookup range (column A) contains two "50" values in cells A5 and A6;
and the formula returns a value from cell B5. Why is that? Because the VLOOKUP
function with exact match returns the 1st found value that matches the lookup value.
Example 2. Using vlookup in Excel with approximate match
When using VLOOKUP formulas with approximate match, i.e. with range_lookup set to
TRUE or omitted, the first thing you need to do is sort the first column in your lookup
range in ascending order.
This is very important because your VLOOKUP formula is going to return the next
largest value for the lookup value you specify and then stop searching. If you neglect to
sort your data properly, you will end up having really strange results or the #N/A error.
=VLOOKUP(69,$A$2:$B$15,2,TRUE)
=VLOOKUP(69,$A$2:$B$15,2)
As you see, I am trying to find the animal whose speed is closest to 69 mph. And here's
what the VLOOKUP formula returns:
As you see, the formula returns "Antelope" whose speed is 61mph, while we also have
Cheetah that runs 70 mile per hour, and 70 is much closer to 69 than 61, isn't it? So,
why is that? Because the VLOOKUP function with approximate match returns the next
largest value that is less than the lookup value.
Hopefully, these examples have shed some light on using VLOOKUP in Excel and this
function is not alien to you any longer : ) Now it may be a good idea to sum up the
essentials you have learned to remember the key points better.
Excel VLOOKUP - things to remember!
1.
Excel VLOOKUP function cannot look at its left. It always searches for the lookup
value in theleft-most column of the lookup range (table_array).
2.
In VLOOKUP formulas, all values are case-insensitive, meaning that uppercase
and lowercase characters are treated as equivalent.
3.
If the lookup value is smaller than the smallest value in the first column of your
lookup range, the VLOOKUP function returns the #N/A error.
4.
If the 3rd parameter (col_index_num) is less than 1, the VLOOKUP formula will
return the #VALUE! error. In case it is greater than the number of columns in your
lookup range (table_array), the formula will return the #REF! error.
5.
Use absolute cell references in the table_array argument of your VLOOKUP
formulas to have the correct lookup range when coping the formulas. Consider using
named ranges or Excel tables as an alternative.
6.
Then you wait for a few second while the Merge Tables Wizard is processing your
data... and here you are:
If this looks like a tool that may be helpful in your work, you are welcome to download a
trial version : )
In the next part of our Excel VLOOKUP tutorial we will explore more advanced
examples such as performing various calculations with VLOOKUP, extracting values
from several columns and more. I thank you for reading and hope to see you next week!
o
o
o
This formula counts how many numbers between 5 and 10 (not including 5 and 10) are
contained in cells C2 through C10.
If you want to count cells based on the same condition but including 5 and 10, add "=" to the
criteria like this: =COUNTIFS(B2:B10,">=5", B2:B10,"<=10")
COUNTIF formulas to count numbers between X and Y:
=COUNTIFS(B2:B11,">0", D2:D11,">0")
Note. You do need to use three separate ranges in the formula, one per column, if you want to
count the products that contain "0" in all the columns. A simpler formula with a single
range =COUNTIFS(B2:D11,"=0") would produce a different result because it returns the total
count of cells containing a zero.
Example 3. How to use cell references in COUNTIFS formulas
Of course, you can use a cell reference instead of a number in Excel COUNTIFS formulas.
Just remember to enclose the operator in quotes ("") and add an ampersand (&) before the cell
reference to construct a text string. For more information about the use of an ampersand in
COUNTIF and COUNTIFS formulas, please see Excel COUNTIF - frequently asked questions.
So, let's make a COUNTIFS formula with a cell reference equivalent to the formula from the
previous example:
=COUNTIFS(B2:B11,"="&C2, C2:C11,"="&C2, D2:D11,"="&C2)
Cell C2 used in the criteria contains a zero value, so the formula will produce exactly the same
result you see in the screenshot above.
Example 4. COUNTIF formulas with OR logic
Examples 2 and 3 above demonstrate how to use COUNTIFS in Excel to count cells based on
several conditions with the AND logic. Such formulas can be applied both to contiguous or noncontiguous ranges. For example, we have used this formula =COUNTIFS(B2:B11,">0",
D2:D11,">0") to find out how many products have a value greater than "0" both in column B
and column D.
But what if you want a total count of cells with a certain value in several non-adjacent ranges or
when at least one of the conditions is met (like OR operator)? For instance, how do you count
the total number of zero values in columns B and D? The answer is to use a combination, more
precisely, a sum of several COUNTIF functions:
=COUNTIF(B2:B11,"=0") + COUNTIF(D2:D11,"=0")
In a similar manner, you can add up several COUNTIFS functions if you want to count
something with the OR logic. For example, the following formula counts the number of rows that
have either "Product1" or "Product2" in column A and 0 in column B:
=COUNTIFS(A2:A11,"Product1", B2:B11, 0) + COUNTIFS(A2:A11,"Product2",
B2:B11, 0)
Example 3. Count dates with multiple conditions based on the current date
You can use Excel's TODAY() function in combination with COUNTIF to count dates based on
the current date.
For example, the following COUNTIF formula with two ranges and two criteria will tell you how
many products have already been purchased but not delivered yet.
=COUNTIFS(C2:C9, "<"&TODAY(), D2:D9, ">"&TODAY())
This formula allows for many possible variations. For instance, you can tweak it to count how
many products were purchased more than a week ago and are not delivered yet:
=COUNTIFS(C2:C9, "<="&TODAY()-7, D2:D9, ">"&TODAY())
If you want to know how many credits a particular student has passed or not passed, you can
utilize either a COUNTIFS or COUNTIF formula, because this time you need a single range
only.
For example, the below formulas will tell you how many credits Bella has passed:
=COUNTIFS(B3:E3,"=P")
=COUNTIF(B3:E3,"=P")
Question mark (?) - matches any single character, use it to count cells starting and/or
ending with certain characters.
Asterisk (*) - matches any sequence of characters, you use it to count cells containing a
specified word or a character(s) as part of the cell's contents.
Tip. If you want to count cells with an actual question mark or asterisk, type a tilde (~) before the
character in your COUNTIFS formula.
Now let's see how you can use a wildcard char in your real COUNTIFS formulas in Excel.
Suppose, you a list of projects assigned to your company's employees. You want to find how
many projects are already assigned to someone, i.e. any name is stated in column A. And
because we are leaning how to use the COUNTIFS function with multiple criteria, let's add a
second condition - the End Date in column D should also be set.
Here is the formula that works a treat: =COUNTIFS(B2:B10,"*",D2:D10,"<>"&""))
Please note, you cannot use a wildcard character criteria with the second range because you
have dates rather that text values in column D. That is why, you use the criteria that finds non-
blankcells - "<>"&""
Important note! Please remember, when you use an Excel COUNTIFS formula with multiple
ranges, all of the ranges must all be the same size, i.e. have the same number of rows and
columns. Otherwise, your formula will return the #VALUE! error. This applies to all COUNTIFS
formulas in Excel, with any data type - numbers, dates and text.
How to rotate charts in Excel - rotate bar, column, pie and line charts
This post describes how to rotate a chart in Excel 2010-2013. You'll learn different ways to spin
bar, column, pie and line charts including their 3-D variations. Besides, you'll see how to reverse
the plotting order of values, categories, series and legend. Those who often print graphs and
charts will read how to adjust the sheet orientation for printing.
Excel makes it really easy to represent your table as a chart or graph. You just select your data
and click on the icon of the suitable chart type. However, the default settings may not work for
you. If your task is to rotate a chart in Excel to arrange the pie slices, bars, columns or lines in a
different way, this article is for you.
o
o
o
o
1. Right-click on any slice of your pie chart and select the option Format Data Series from the
menu.
2. You'll get the Format Data Series pane. Go to the Angle of first slice box, type the number of
degrees you need instead of 0 and press Enter. I think 190 degrees will work fine for my pie
chart.
After being rotated my pie chart in Excel looks neat and well-arranged.
Thus, you can see that it's quite easy to rotate an Excel chart to any angle till it looks the way
you need. It's helpful for fine-tuning the layout of the labels or making the most important slices
stand out.
Rotate 3-D charts in Excel: spin pie, column, line and bar charts
I think 3-D charts look awesome. When other people see your 3-D chart, they may believe you
know it all about Excel visualization techniques. If a graph created with the default settings
doesn't look the way you need, you can adjust it by rotating it and changing the perspective.
1. Right-click on your chart and select 3-D Rotation from the menu list.
2. You'll get the Format Chart Area pane with all available settings. Enter the necessary number
of degrees in the X and Y Rotation boxes.
I changed the numbers to 40 and 35 correspondingly to make my chart look slightly deeper.
This pane also lets you adjust Depth and Height, as well as Perspective. Just play with the
options to see which suite best for your type of chart. Feel free to use the same steps for pie
charts as well.
Rotate charts to 180 degrees: change the order of categories, values, or series
If the chart you need to rotate in Excel displays Horizontal and Vertical axes, you can quickly
reverse the order of the categories or values plotted along those axes. Additionally, in 3-D charts
that have a depth axis, you can flip the plotting order of data series so that large 3-D columns do
not block smaller ones. You can also reposition the Legend on your pie or column chart in Excel.
1. Right click on the Horizontal axis and select the Format Axis item from the menu.
2. You'll see the Format Axis pane. Just tick the checkbox next to Categories in reverse order to
see you chart rotate to 180 degrees.
1. Right-click on the Vertical (Value) Axis and pick the option Format Axis.
Note. Please remember that it's not possible to reverse the plotting order of values in a radar
chart.
Reverse the plotting order of data series in a 3-D chart
If you have a column or line chart with the third axis, which shows some columns (lines) in front
of others, you can change the plotting order of data series so that large 3-D data markers do not
overlap smaller ones. You can also use the below steps to create two or more charts for
showing all values from the legend.
1. Right-click on the Depth (Series) Axis on the chart and select the Format Axis menu item.
2. You will get the Format Axis pane open. Tick the Series in reverse order checkbox to see the
columns or lines flip.
1. Right click on the Legend and select the Format Legend option.
2. Select one of the checkboxes you will see on the Legend options pane: Top, Bottom, Left,
Right orTop right.
to change the layout to a landscape mode for my picture to look correct on the printable.
Now when I go to the Print Preview window I can see that my chart fits perfectly.
Use the Camera tool to rotate your Excel chart to any angle
You can rotate your chart to any angle using the Camera tool in Excel. It allows you to place the
result next to your original chart or insert the picture to a new sheet.
Tip. If you want to rotate your chart by 90 degrees, it may be a good idea to simply modify the
chart type. For example, from column to bar.
You can add the Camera tool if you go to the Quick Access tool bar and click on the small drop
down arrow. Select the option More Commands
Add Camera by choosing it from the list of all commands and clicking Add.
Now follow the steps below to make the Camera option work for you.
Note. Please remember, it's not possible to place the Camera tool over your chart since the
result is unpredictable.
2. You may need to flip the alignment of your chart axis to 270 degrees using the Format
Axisoption I described above. Therefore, the labels will be readable when the chart is rotated.
7. Rotate your chart in Excel to the needed angle and drop the control.
Note. There is one problem with using the Camera tool. The resulting objects may have a
reduced resolution from the actual chart. They may look grainy or pixelated.
Creating a chart is a really good way to showcase your data. Charts in Excel are easy-to-use,
comprehensive, visual and can be adjusted to look the way you need. Now you know how to
rotate your column, bar, pie or line chart.
Having written all the above I feel like a real chart rotation guru. Hope my article will help you
with your task as well. Be happy and excel in Excel!
If you often create summary reports with Excel Pivot Table functionality, sometimes you may
need to turn your crosstab table to list. The point is that many analysis and visualization tools,
like Tableau, or Protovis, don't work with pivoted data. Here you start searching for a VBA macro
or any other possibility to transform your summary table to list. Good news is that you can
simply use Unpivot Table add-in and get the necessary results in seconds.
Unpivot your Excel table in seconds
The Unpivot Table tool is a part of Ultimate Suite by Ablebits. Thus to try it out, please download
and install the latest version of Ultimate Suite to your PC.
When you open Excel, you will see the Unpivot Table icon under the Ablebits Data tab in
theTransform section.
Just open your Pivot Table by clicking on its icon, choose if you want to separate the resulting
parts by an empty row and select the destination for your list. It's possible to place the results to
a new workbook or worksheet.
That's it! Forget the time when you needed to spend hours manipulating and transforming your
spreadsheets. Unpivot Table for Excel will normalize your crosstab list and will prepare it for
further processing with complex visualization
o
o
o
o
o
o
o
range - defines one or several cells to count. You put the range in a formula like you
usually do in Excel, e.g. A1:A20.
criteria - defines the condition that tells the function which cells to count. It can be
a number,text string, cell reference or expression. For instance, you can use the criteria like
these: "10", A2, ">=10", "some text".
And here is the simplest example of Excel COUNTIF function. What you see in the image below
is the list of the best tennis players for the last 14 years. The
formula =COUNTIF(C2:C15,"Roger Federer") counts how many times Roger Federer's
Note. A criterion is case insensitive, meaning that if you type "roger federer" as the criteria in the
above formula, this will produce the same result.
Excel COUNTIF function examples
As you have just seen, the syntax of the COUNTIF function is very simple. However, it allows for
many possible variations of the criteria, including wildcard characters, the values of other cells,
and even other Excel functions. This diversity makes the COUNTIF function really powerful and
fit for many tasks, as you will see in the examples that follow.
COUNTIF formula for text and numbers (exact match)
In fact, we discussed the COUNTIF function that counts text values matching a specified
criterion exactly a moment ago. Let me remind you that formula for cells containing an exact
string of text: =COUNTIF(C2:C15,"Roger Federer"). So, you enter:
Column D.
An asterisk (*) is used to find cells with any sequence of leading and trailing characters, as
illustrated in the above example. If you need to match any single character, enter a question
mark (?) instead, as demonstrated below.
Count cells beginning or ending with certain characters
You can use either wildcard character, asterisk (*) or question mark (?), with the criterion
depending on which exactly result you want to achieve.
If you want to know the number of cells that start or end with certain text no matter how many
other characters a cell contains, use these formulas:
=COUNTIF(C2:C10,"Mr*") - count cells that begin with "Mr".
=COUNTIF(C2:C10,"*ed") - count cells that end with the letters "ed".
The image below demonstrates the second formula in action:
If you are looking for a count of cells that start or end with certain letters and contain the exact
number of characters, you use the Excel COUNTIF function with the question mark character
(?) in the criteria:
=COUNTIF(D2:D9,"??own") - counts the number of cells ending with the letters "own" and
having exactly 5 characters in cells D2 through D9, including spaces.
=COUNTIF(D2:D9,"Mr??????") - counts the number of cells starting with the letters "Mr"
and having exactly 8 characters in cells D2 through D9, including spaces.
Tip. To find the number of cells containing an actual question mark or asterisk, type a tilde (~)
before the ? or * character in the formula. For example, =COUNTIF(D2:D9,"*~?*") will count
all cells containing the question mark in the range D2:D9.
Excel COUNTIF for blank and non-blank cells
These formula examples demonstrate how you can use the COUNTIF function in Excel to count
the number of empty or non-empty cells in a specified range.
COUNTIF not blank
In some of other Excel COUNTIF tutorials, you may come across formulas for counting nonblank cells in Excel similar to this one:
=COUNTIF(range,"*")
But the fact is, the above formula counts all cells that contain any text, meaning that cells with
dates and numbers will be treated as blank cells!
If you need a universal COUNTIF formula for counting all non-blank cells in a specified range,
here you go:
=COUNTIF(range,"<>"&"")
This formula works correctly with all value types - text, dates and numbers - as you can see in
the screenshot below.
COUNTIF blank
If you want the opposite, i.e. count blank cells in a certain range, you should adhere to the same
approach - use a formula with a wildcard character for text values or another one (with the ""
criteria) to count all empty cells.
Formula to count cells not containing any text: =COUNTIF(range,"<>"&"*")
Translated into plain English, the criteria used in the above formula ("<>"&"*") means to find
cells not equal to *, i.e. not containing any text in the specified range.
Universal COUNTIF formula for blanks (all value types): =COUNTIF(range,"")
The above formula correctly handles numbers, dates and text values. For example, the
formula =COUNTIF(C2:C11,"") returns the number of all empty cells in the range C2:C11.
Note. Please be aware that Microsoft Excel provides another function for counting blank cells
=COUNTBLANK(range). For instance, the below formulas will produce exactly the same
results as the COUNTIF formulas you see in the screenshot above:
Count blanks: =COUNTBLANK(C2:C11)
Formula Example
Description
=COUNTIF(A2:A10,"
>5")
=COUNTIF(A2:A10,"
<5")
Count if equal to
=COUNTIF(A2:A10,"
=5")
=COUNTIF(A2:A10,"
<>5")
=COUNTIF(C2:C8,">
=5")
=COUNTIF(C2:C8,"<
=5")
You can also use all of the above formulas to count cells based on another cell value, you
will just need to replace the number in the criteria with a cell reference.
Note. In case of a cell reference, you have to enclose the operator in quotes and add an
ampersand (&) before the cell reference. For example, to count cells in the range D2:D9 with
values greater than a value in cell D3, you use this formula =COUNTIF(D2:D9,">"&D3):
If you want to count cells that contain an actual operator as part of the cell's contents, i.e. the
characters ">", "<" or "=", then use a wildcard character with the operator in the criteria. Such
criteria will be treated as a text string rather than a numeric expression. For example, the
formula =COUNTIF(D2:D9,"*>5*") will count all cells in the range D2:D9 with contents like
this "Delivery >5 days" or ">5 available".
Using Excel COUNTIF function with dates
If you want to count cells with dates that are greater than, less than or equal to the date you
specify or date in another cell, you proceed in the already familiar way using formulas similar to
the ones we discussed a moment ago. All of the above formulas work for dates as well as for
numbers. Let me give you just a few examples:
Criteria
Formula Example
Description
=COUNTIF(B2:B10,"6/1/20
14")
=COUNTIF(B2:B10,">=6/1
/2014")
=COUNTIF(B2:B10,">="&
B2-"7")
Apart from these common usages, you can utilize the COUNTIF function in conjunction with
specific Excel Date and Time functions such as TODAY() to count cells based on the current
date.
Criteria
Formula Example
=COUNTIF(A2:A10,TODAY())
=COUNTIF(A2:A10,"<"&TODAY())
=COUNTIF(A2:A10,">"&TODAY())
=COUNTIF(A2:A10,"="&TODAY()+7)
Here is an example of using such formulas on real data (at the moment of writing today was 25Jun-2014):
can use the following formula to count cells in the range B2:B9 where a value is greater than 5
and less than 15.
=COUNTIF(B2:B9,">5")-COUNTIF(B2:B9,">=15")
Please pay attention to the wildcard character (*) in the second criterion, it is used to count all
kinds of juice on the list.
In the same manner, you can write a COUNTIF formula with several conditions. Here is an
example of the COUNTIF function with multiple conditions that counts lemonade, juice and
ice cream:
=COUNTIF(B2:B13,"Lemonade") + COUNTIF(B2:B13,"*juice") +
COUNTIF(B2:B13,"Ice cream")
You can find plenty more examples for text, numbers and dates in this tutorial - Excel
COUNTIFS and COUNTIF with multiple criteria.
Using COUNTIF function to find duplicates and unique values
Another possible usage of the COUNTIF function in Excel is for finding duplicates in one
column, between two columns, or in a row.
Example 1. Find and count duplicates in 1 column
For example, this simple formula =COUNTIF(B2:B10,B2)>1 will spot all duplicate entries in the
range B2:B10 while another function =COUNTIF(B2:B10,TRUE) will tell you how many dupes
are there:
Tip. If you want to highlight duplicate cells or entire rows containing duplicate entries, you can
create conditional formatting rules based on the COUNTIF formulas, as demonstrated in this
tutorial - Excel conditional formatting formulas to highlight duplicates.
Example 3. Count duplicates and unique values in a row
If you want to count duplicates or unique values in a certain row rather than a column, use one
of the below formulas. These formulas might be helpful, say, to analyze the lottery draw history.
Count duplicates in a row:
=SUMPRODUCT((COUNTIF(A2:I2,A2:I2)>1)*(A2:I2<>""))
Count unique values in a row:
=SUMPRODUCT((COUNTIF(A2:I2,A2:I2)=1)*(A2:I2<>""))
An alternative way is using the INDIRECT function to create an array of ranges. For example,
both of the below formulas produce the same result you see in the screenshot:
=SUM(COUNTIF(INDIRECT({"B2:B8","D2:C8"}),"=0"))
=COUNTIF($B2:$B8,0) + COUNTIF($C2:$C8,0)
If you use a number or a cell reference in the exact match criteria, you need neither
ampersand nor quotes, e.g. or =COUNTIF(A1:A10,10) or =COUNTIF(A1:A10,C1).
If your criteria includes text, wildcard character or some operator with a number, you
enclose it in quotes,
e.g. =COUNTIF(A2:A10,"lemons") or =COUNTIF(A2:A10,"*") or =COUNTIF(A2:A10,"
>5")
If you use an expression with a cell reference or another Excel function, you have to
use the quotes ("") to start a text string and ampersand (&) to concatenate and finish the string
off. For example, =COUNTIF(A2:A10,">"&D2) or =COUNTIF(A2:A10,"<="&TODAY()).
If you are in doubt whether an ampersand is needed or not, try out both ways. In most cases an
ampersand works just fine, e.g. the formulas =COUNTIF(C2:C8,"<=5") and
=COUNTIF(C2:C8,"<="&5) work equally well.
3. COUNTIF for formatted (color coded) cells
Question: How do I count cells by fill or font color rather than by values?
Answer: Regrettably, the syntax of the Excel COUNTIF function does not allow using formats as
the condition. The only possible way to count or sum cells based on their color is using a macro,
or more precisely an Excel User-Defined function. You can find the code working for cells
colored manually as well as for conditionally formatted cells in this article - How to count, sum
and filter cells by color in Excel.
4. #NAME? error in the COUNTIF formula
Issue: My COUNTIF formula throws a #NAME? error. How can I get it fixed?
Answer: Most likely, you have supplied an incorrect range to the formula. Please check out point
1above.
5. Excel COUNTIF formula not working
Issue: My COUNTIF formula is not working! What have I done wrong?
Answer: If you have written a formula which is seemingly correct but it does not work or
produces a wrong result, start by checking the most obvious things such as a range, conditions,
cell references, use of ampersand and quotes.
Be very careful with using spaces in a COUNTIF formula. When creating one of the formulas
for this article I was on the verge of pulling my hair out because the correct formula (I knew with
certainty it was right!) wouldn't work. As it turned out, the problem was in a measly space
somewhere in between, argh... For instance, look at this formula =COUNTIF(B2:B13,"
Lemonade"). At first sight, there is nothing wrong about it, except for an extra space after the
opening quotation mark. Microsoft Excel will swallow the formula just fine without an error
message, warning or any other indication, assuming you really want to count cells containing
the word 'Lemonade' and a leading space.
If you use the COUNTIF function with multiple criteria, split the formula into several pieces and
verify each function individually.
And this is all for today. In the next article, we will explore several ways to count cells in Excel
with multiple conditions. Hope to see you next week and thanks for reading!
You need to make Excel count blank cells in your sheet or find and select them to see how
many stores didn't provide the necessary details. Doing it manually would take too much time,
so feel free to use one of the options I show in this post:
1. Select a range with blank cells in your table and press F5 on the keyboard to get the Go
Todialog box.
2. Then press the Alt + S hotkey to get the Go To Special window. On this window, select
theBlanks radio button.
3. Click Ok to see the empty cells found and highlighted in your table.
Tip. You can use the Fill Color option under the Home tab to change the background of empty
cells and keep the selection.
Please note that Go to Special will not find pseudo-blank cells with spaces or those with
formulas that return blanks.
Excel - count blank cells using Find and Replace functionality
You can use the standard Excel Find and Replace dialog to count empty cells in your table. This
tool will display the list with all blanks next to their addresses in your sheet. It also lets
you navigate to any empty cell by clicking on its link in the list.
1. Select the range where you need to count blank cells and press the Ctrl + F hotkey.
Note. If you select one cell Find and Replace will search the entire table.
2. Leave the Find what field empty.
3. Press Options and select the Match entire cell contents checkbox.
If you choose to find Values, the tool will count all empty cells including the pseudo-blank
ones.
Select the Formulas option to search for empty cells only. You will not get cells with
blank formulas or spaces.
5. Press the Find All button to see the results. You will get the number of blanks in the bottomleft corner.
Tip. If you select the results on the add-in pane, it's possible to fill the empty cells with the same
value, like 0 or the words "no information". To learn more, please check the article Fill empty
cells with 0 or another specific value.
Use a special formula for counting blank cells
This part is for the formula-oriented users. Though you will not see the found items highlighted,
it's possible to get the number of blanks in any cell you select to compare to the next search.
The formula =countblanks() will show you the number of empty cells, including the
pseudo-blank ones.
If you enter the formula =ROWS()*COLUMNS()-COUNTA(), you'll get all truly
empty cells. No values, no blank formulas.
Follow the steps below to apply them:
1. Select any empty cell in your sheet.
2. Enter =countblanks() or =ROWS() * COLUMNS() - COUNTA() into the formula bar.
3. Then you can enter the range address between the brackets in your formula. Or place the
mouse cursor between the brackets and manually select the necessary cell range in your sheet.
You will see the address automatically appear in the formula.
4. Press Enter on your keyboard.
You will get the result in the selected cell.
On the below picture, I show the summary of how these 2 formulas work with constants and
pseudo-blank cells. In my sample, I have 4 cells selected. A2 has a value, A3 has a formula that
returns an empty string, A4 is empty and A5 contains two spaces. Below the range, you can see
the number of the found cells next to the formula I employed.
You can also use the COUNTIF formula for counting empty cells in Excel, please check out this
tutorial for full details - COUNTIF for blanks and non-blanks.
Now you know how to find and count blank cells in your Excel table. Use a formula to paste the
number of empty cells, turn on Find and Replace to highlight blanks, navigate to them and see
their number, or choose the Go To Special feature to quickly select all blank ranges in your
table. Feel free to share any other hints you may have. Be happy and excel in Excel!
Excel - count non-blank cells with the Find and Replace option
It's also possible to count non-empty cells with the help of the standard Excel Find and
Replacedialog. This method is good if you have a large table. You'll get all values displayed on
one window along with their cell addresses. In addition, you can easily navigate to any item by
clicking on its name in the list.
1. Select the range where you need to count the non-blanks and press the Ctrl + F hotkey.
2. You will see the Find and Replace dialog box. Enter the asterisk symbol ( * ) in the Find
what field.
3. Press the Options button and pick the Values or Formulas item from the Look in: drop-down
list.
If you select Values, the tool will count all filled cells and ignore blank formulas.
When you pick Formulas, Find and Replace shows all cells that have values and any
formulas.
4. Click Find All to see the results. You'll get all the found items and their quantity on the pane.
Tip. You can now select all found items on the Find and Replace pane. You'll see all non-blank
cells highlighted and it will stay after you close the window.
With the formula =ROWS() * COLUMNS()-COUNTBLANK() you need to enter the range
address 3 times.
4. Press Ctrl + Shift + Enter to see the number in the selected cell.
On the screenshot below, you can see a brief summary showing how these 3 formulas work
with constants, blank formulas and extra spaces. In the test table I have a range with 4 cells
selected. A2 contains a value, A3 has a formula that returns an empty string, A4 is empty and
A5 has two spaces entered. Under the range, you can see the number of the found cells next to
How to conditionally format dates and time in Excel - built-in rules and formulas
If you are a regular visitor of this blog, you've probably noticed a few recent articles covering
different aspects of Excel conditional formatting. Those tutorials explain how to apply Excel's
built-in rules and make your own conditional formats based on formulas.
And now we will leverage this knowledge and create spreadsheets that differentiate between
weekdays and weekends, highlight public holidays and display a coming deadline or delay. In
other words, we are going to apply Excel conditional formatting to dates.
If you have some basic knowledge of Excel formulas, then you are most likely familiar with
some of date and time functions such as NOW, TODAY, DATE, WEEKDAY, etc. In this tutorial,
we are going to take this functionality a step further to conditionally format Excel dates in the
way you want.
o
o
o
o
o
o
o
1. To apply the formatting, you simply go to the Home tab > Conditional Formatting > Highlight
Cell Rules and select A Date Occurring.
2. Select one of the date options from the drop-down list in the left-hand part of the window,
ranging from last month to next month.
3. Finally, choose one of the pre-defined formats or set up your custom format by choosing
different options on the Font, Border and Fill tabs. If the Excel standard palette does not suffice,
However, this fast and straightforward way has two significant limitations - 1) it works for
selected cells only and 2) the conditional format is always applied based on the current date.
Tip. If you want to display only the days of the week like you see in the image above, select the
cells with the formula (row 5 in our case), right-click and choose Format Cells...> Number >
Custom. From the drop-down list under Type, select either dddd or ddd to show full day names
or abbreviated names, respectively.
Your Excel calendar is almost done, and you only need to change the color of weekends.
Naturally, you are not going to color the cells manually. We'll have Excel format the weekends
automatically by creating a conditional formatting rule based on the WEEKDAY formula.
1. You start by selecting your Excel calendar where you want to shade the weekends. In our
case, it is the range $B$4:$AE$10. Be sure to start the selection with the 1st date column Colum B in this example.
2. On the Home tab, click Conditional Formatting menu > New Rule.
3. Create a new formatting rule based on a formula, as explianed in How to create Excel
conditional formatting rules with a formula.
4. In the "Format values where this formula is true" box, enter the following WEEKDAY formula
that will determine which cells are Saturdays and Sundays: =WEEKDAY(B$5,2)>5
5. Click the Format... button and set up your custom format by switching between
the Font,Border and Fill tabs and playing with different formatting options. When done, click
the OK button to preview the rule.
The serial_number parameter represents the date you are trying to find. You enter a
reference to your first cell with a date, B$5 in our case.
The [return_type] parameter determines the week type (square brackets imply it is
optional). You enter 2 as the return type for a week starting from Monday (1) through Sunday
(7). You can find the full list of available return types here.
Finally, you write >5 to highlight only Saturdays (6) and Sundays (7).
The screenshot below demonstrates the result in Excel 2013 - the weekends are highlighted in
the reddish colour.
Tips:
If you have non-standard weekends in your company, e.g. Fridays and Saturdays, then
you would need to tweak the formula so that it starts counting from Sunday (1) and highlight
days 6 (Friday) and 7 (Saturday) - WEEKDAY(B$5,1)>5.
If you are creating a horizontal (landscape) calendar, use a relative column (without $)
and absolute row (with $) in a cell reference because you should lock the reference of the row in the above example it is row 5, so we entered B$5. But if you are designing a calendar in
vertical orientation, you should do the opposite, i.e. use an absolute column and relative row,
e.g. $B5 as you can see in the screenshot below:
Again, you open Conditional Formatting > New Rule. In the case of holidays, you are going to
use either MATCH or COUNTIF function:
=COUNTIF($A$14:$A$17,B$5)>0
=MATCH(B$5,$A$14:$A$17,0)
Note. If you have chosen a different color for holidays, you need to move the public holiday rule
to the top of the rules list via Conditional Formatting > Manage Rules...
The following image shows the result in Excel 2013:
The screenshot below demonstrates the result of such conditional formatting rule for dates.
That was actually the major part of the work and now you only need to create a conditional
formatting rule for the entire table with this very simple formula: =$C2=41772. The formula
implies that your table has headers and row 2 is your first row with data.
An alternative way is to use the DATEVALUE formula that converts the date to the number
format is which it is stored, e.g. =$C2=DATEVALUE("5/13/2014")
Whichever formula you use, it will have the same effect:
formatting date formula to color the Invoice column when the Delivery Date is equal to or greater
than today BUT you want the formatting to disappear when you enter the invoice number.
For this task, you would need an additional column with the following formula (where E is
yourDelivery column and F the Invoice column):
=IF(E2>=TODAY(),IF(F2="", 1, 0), 0)
If the delivery date is greater than or equal to the current date and there is no number in the
Invoice column, the formula returns 1, otherwise it's 0.
After that you create a simple conditional formatting rule for the Invoice column with the
formula =$G2=1 where G is your additional column. Of course, you will be able to hide this
column later.
In the formula, we enter 1 as the 3rd parameter since it indicates Saturday and Sunday as
holidays. You can use another value if your weekends are different, say, Fri and Sat. The full list
of the weekend values is available here. Optionally, you can also use the 4th parameter
[holidays], which is a set of dates (range of cells) that should be excluded from the working day
calendar.
And finally, you may want to highlight rows depending on how far away the deadline is. For
example, the conditional formatting rules based on the following 2 formulas highlight upcoming
and recent end dates, respectively:
Here are a few more formula examples that can be applied to the table above:
=$D2<TODAY() - highlights all passed dates (i.e. dates less than the current date). Can be
used to format expired subscriptions, overdue payments etc.
=$D2>TODAY() - highlights all future dates (i.e. dates greater than the current date). You can
use it to highlight upcoming events.
Of course, there can be infinite variations of the above formulas, depending on your particular
task. For instance:
=$D2-TODAY()>=6 - highlights dates that occur in 6 or more days.
=$D2=TODAY()-14 - highlights dates occurring exactly 2 weeks ago.
How to highlight dates within a date range
If you have a long list of dates in your worksheet, you may also want to highlight the cells or
rows that fall within a certain date range, i.e. highlight all dates that are between two given
dates.
You can fulfil this task using the TODAY() function again. You will just have to construct a little bit
more elaborate formulas as demonstrated in the examples below.
Formulas to highlight past dates
The current date and any future dates are not colored.
are until their next birthday? Moreover, how many days exactly are left until your wedding
anniversary and other events you wouldn't want to miss? Easily!
The formula you need is this (where A is your Date column):
=DATEDIF(TODAY(),DATE((YEAR(TODAY())+1),MONTH($A2),DAY($A2)),"yd")
The "yd" interval type at the end of the formula is used to ignore years and calculate the
difference between the days only. For the full list of available interval types, look here.
Tip. If you happen to forget or misplace that complex formula, you can use this simple one
instead: =365-DATEDIF($A2,TODAY(),"yd"). It produces exactly the same results, just
remember to replace 365 with 366 in leap years : )
And now let's create an Excel conditional formatting rule to shade different gaps in different
colors. In this case, it makes more sense to utilize Excel Color Scales (Conditional formatting >
Color Scales) rather than create a separate rule for each period.
The screenshot below demonstrates the result in Excel - a gradient 3-color scale with tints from
green to red through yellow.
Tip. You can also select entire lines using the row number buttons. You'll see the number of the
highlighted rows next to the last button.
You will see your table in Excel with the rows inserted below the necessary line.
You can get the same result if you use the Insert menu option. Please see the steps below.
1. Select the cells where the empty rows need to appear and press Shift + Space.
2. When you pick the correct number of rows, right-click within the selection and choose
the Insertoption from the menu list.
Tip. If your cells contain any formatting, use the Insert Options icon to match the format.
Again, you'll see multiple rows inserted in your table in Excel. Now you can enter the necessary
details to get your report ready.
Excel - Insert row shortcuts to speed up pasting blanks
If you think that the ways described above are fast enough, check out the below options to see
what is really quick. I'll share how to insert new rows in Excel with keyboard shortcuts.
The first shortcut I'd like to cover is the one repeating the Ribbon option Insert Sheet Rows.
1. Select the necessary number of rows where the blank lines will appear by picking the
corresponding cells and pressing Shift + Space. The current content will be moved down to
Voila! You can see the new rows added below. Please keep reading - the most interesting
details are ahead.
If you prefer to use the main keyboard, you can get the same results if you use the Ctrl + Shift +
Plus on the main pad.
Tip. If you need to add numerous rows at a time, like one or two hundred, take the advantage of
the F4 button. It repeats your last action. For example, if you want to insert 100 empty rows,
select a range with 10 rows, use the shortcut you like to insert the blanks and then just
press F4ten times.
Special shortcut to insert rows in Excel if there's data to the right of your table
Ctrl + Plus hotkey is fast and reliable, but if you have data to the right of your main table like on
the screenshot below, it may insert blanks where you wouldn't like them to be and break the
structure.
If that's your case, in this part you'll find a solution for inserting multiple new rows in your Excel
table and keeping the structure of the data next to your list as is.
1. Format your data as Excel Table using the shortcut Ctrl + T, or go to the Home tab -> Format
as Table button and pick the style that suites you best.
You will see the Create Table dialog box that will help you select the necessary range.
That's how your data look like after being formatted as Excel Table:
2. Now that your list is formatted, select a range within your table.
3. Hold the Alt key, first press H, then press I and finally - A. This is a shortcut for the
optionInsert Table Rows Above.
Tip. You can achieve the same result if you select the necessary range and press Ctrl + Plus on
the numerical keypad.
As you can see, new rows didn't appear between the rows to the right:
2. Press the Insert button on the Ribbon or use any Excel shortcut I listed above to see the
results.
The second option will suite better if you have a big data table.
1. Create a helper column. Enter 1 and 2 in the starting cells, grab the fill handle and drag it to
the last data cell.
2. Now copy the series in the helper column and paste the range just below the last cell.
3. Select the entire table, go to the Data tab in Excel and press the Sort button.
4. On the window that will appear choose to sort by your Helper column (in my example its
column D) -> Values -> Smallest to Largest.
5. Click OK and see the results. Empty rows will appear between the lines with data.
o
o
Select the cells you want to format. You can select one column, several columns or the
entire table if you want to apply your conditional format to rows.
Tip. If you plan to add more data in the future and you want the conditional formatting rule to
get applied to new entries automatically, you can either:
Convert a range of cells to a table (Insert tab > Table). In this case, the
conditional formatting will be automatically applied to all new rows.
Select some empty rows below your data, say 100 blank rows.
2.
3.
In the New Formatting Rule window, select Use a formula to determine which cells to
format.
4.
Enter the formula in the corresponding box.
5.
Click the Format button to choose your custom format.
6.
Switch between the Font, Border and Fill tabs and play with different options such as
font style, pattern color and fill effects to set up the format that works best for you. If the
standard palette does not suffice, click More colors and choose any RGB or HSL color to
your liking. When done, click the OK button.
7.
Make sure the Preview section displays the format you want and if it does, click
the OK button to save the rule. If you are not quite happy with the format preview, click
Tip. For your Excel conditional formatting formula to work correctly, please always follow these
simple rules.
Formulas to compare values (Greater than, Less than, Equal to)
Compare values based on several conditions (OR and AND formulas)
Formulas for blanks and non-blanks
Formulas for text values
Formulas to highlight duplicates
Format values above or below average
Highlight the nearest value in the data set
Formulas to compare values (numbers and text)
As you know Microsoft Excel provides a handful of ready-to-use rules to format cells with values
greater than, less than or equal to the value you specify (Conditional Formatting >Highlight
Cells Rules). However, these rules do not work if you want to conditionally format certain
columns or entire rows based on a cell's value in another column. In this case, you use
analogous formulas:
Condition
Formula example
Equal to
=$B2=10
Not equal to
=$B2<>10
Greater than
=$B2>10
=$B2>=10
Less than
=$B2<10
=$B2<=10
Between
=AND($B2>5, $B2<10)
The screenshot below shows an example of the Greater than formula that highlights product
names in column A if the number of items in stock (column C) is greater than 0. Please pay
attention that the formula applies to column A only ($A$2:$A$8). But if you select the whole
table (in our case, $A$2:$E$8), this will highlight entire rows based on the value in column C.
In a similar fashion, you can create a conditional formatting rule to compare values of two cells.
For example:
=$A2<$B2 - format cells or rows if a value in column A is less than the corresponding value in
column B.
=$A2=$B2 - format cells or rows if values in columns A and B are the same.
=$A2<>$B2 - format cells or rows if a value in column A is not the same as in column B.
As you can see in the screenshot below, these formulas work for text values as well as for
numbers.
Formula
Description
=AND($B2<$C2,
$C2<$D2)
=OR($B2<$C2,
$C2<$D2)
Naturally, you can use two, three or more conditions in your =AND and =OR formulas.
These are the basic conditional formatting formulas you use in Excel. Now let's consider a bit
more complex but far more interesting examples.
But what if you want to format cells in a certain column if a corresponding cell in another column
is empty or not empty? In this case, you will need to utilize Excel formulas again:
Formula for blanks: =$B2="" - format selected cells / rows if a corresponding cell in Column B
is blank.
Formula for non-blanks: =$B2<>"" - format selected cells / rows if a corresponding cell in
Column B is not blank.
Note. The formulas above will work for cells that are "visually" empty or not empty. If you use
some Excel function that returns an empty string, e.g. =if(false,"OK", ""), and you don't want
such cells to be treated as blanks, use the following formulas
instead =isblank(A1)=true or=isblank(A1)=false to format blank and non-blank cells,
respectively.
And here is an example of how you can use the above formulas in practice. Suppose, you have
a column (B) which is "Date of Sale" and another column (C) "Delivery". These 2 columns have
a value only if a sale has been made and the item delivered. So, you want the entire row to turn
orange when you've made a sale; and when an item is delivered, a corresponding row should
turn green. To achieve this, you need to create 2 conditional formatting rules with the following
formulas:
Green rows (cells in column B and column C are not empty): =AND($B2<>"",
$C2<>"")
One more thing for you to do is to move the second rule to the top and select the Stop if
truecheck box next to this rule:
In this particular case, the "Stop if true" option is actually superfluous, and the rule will work with
or without it. You may want to check this box just as an extra precaution, in case you add a few
other rules in the future that may conflict with any of the existing ones.
Excel formulas to work with text values
If you want to apply conditional formatting to selected columns when another cell in the same
row contains a certain word, you can use a simple formula like =$D2="Worldwide" (we've
used a similar formula in one of the previous examples). However, this formula will work
forexact match only.
For partial match, you will need another Excel function: =SEARCH. You use it in this way:
Select the column where you want to highlight duplicates, without the column header.
Create a conditional formatting rule(s) using these simple formulas:
Rule 1 (blue): =$A1=$A2 - highlights the 2nd occurrence and all subsequent occurrences, if any.
Rule 2 (green): =$A2=$A3 - highlights the 1st occurrence.
In the above formulas, A is the column you want to check for dupes, $A1 - the column header,
$A2 - the first cell with data.
Important! For the formulas to work correctly, it is essential that Rule 1, which highlights the
2ndand all subsequent duplicate occurrences, should be the first rule in the list, especially if you
are using two different colors.
As you can see, Excel conditional formatting formulas cope with dupes pretty well. However, for
more complex cases, I would recommend using the Duplicate Remover add-in that is especially
designed to find, highlight and remove duplicates in Excel 2013, 2010, 2007 and 2003, in one
sheet or between two spreadsheets.
Formulas to highlight values above or below average
When you work with several sets of numeric data, the =AVERAGE function may come in handy
to format cells whose values are below or above the average in a column.
For example, you can use the formula =$E2<AVERAGE($E$2:$E$8) to conditionally format the
rows where the sale numbers are below the average, as shown in the screenshot below. If you
are looking for the opposite, i.e. to shade the products performing above the average, replace
"<" with ">" in the formula: =$E2>AVERAGE($E$2:$E$8).
Please pay attention to the use of absolute references in the address of the cell containing the
array formula ($C$2), because this cell is constant. Also, you need to replace 0 with the number
for which you want to highlight the closest match. For example, if we wanted to highlight the
value nearest to 5, the formula would change to: =OR(B3=5-$C$2,B3=5+$C$2)
Example 2. Highlight a value closest to the given value, but NOT exact match
In case you do not want to highlight the exact match, you need a different array formula that will
find the closest value but ignore the exact match.
For example, the following array formula finds the value closest to 0 in the specified range, but
ignores zeroes, if any:
=MIN(ABS(B3:C13-(0))+(10^0*(B3:C13=0)))
Please remember to press Ctrl + Shift + Enter after you finished typing your array formula.
The conditional formatting formula is the same as in the above example:
=OR(B3=0-$C$2,B3=0+$C$2)
However, since our array formula in cell C2 ignores the exact match, the conditional formatting
rule ignores zeroes too and highlights the value 0.003 that is the closest match.
If you want to find the value nearest to some other number in your Excel sheet, just replace "0"
with the number you want both in the array and conditional formatting formulas.
I hope the conditional formatting formulas you have learned in this tutorial will help you make
sense of whatever project you are working on. If you need more examples, please check out the
following articles:
Use absolute & relative cell addresses correctly. It's very difficult to deduce a general
rule that will work in 100 per cent of cases. But most often you would use an absolute
column (with $) and relative row (without $) in your cell references, e.g. =$A1>1.
Please keep in mind that the formulas =A1=1, =$A$1=1 and =A$1=1 will produce different
results. If you are not sure which one is correct in your case, you can try all : ) For more
information, please see Relative and absolute cell references in Excel conditional formatting.
2.
Verify the applied range. Check whether your conditional formatting rule applies to the
correct range of cells. A rule of thumb is this - select all the cells / rows you want to format
but do not include column headers.
3.
Write the formula for the top-left cell. In conditional formatting rules, cell references
are relative to the top-left most cell in the applied range. So, always write your conditional
formatting formula for the 1st row with data.
For example, if your data starts in row 2, you put =A$2=10 to highlight cells with values
equal to 10 in all the rows. A common mistake is to always use a reference to the first row
(e.g. =A$1=10). Please remember, you reference row 1 in the formula only if your table does
not have headers and your data really starts in row 1. The most obvious indication of this
case is when the rule is working, but formats values not in the rows it should.
4.
Check the rule you created. Double-check the rule in the Conditional Formatting Rules
Manager. Sometimes, for no reason at all, Microsoft Excel distorts the rule you have just
created. So, if the rule is not working, go to Conditional Formatting > Manage Rules and
check both the formula and the range it applies to. If you have copied the formula from the
web or some other external source, make sure the straight quotes are used.
5.
Adjust cell references when copying the rule. If you copy Excel conditional
formatting using Format Painter, don't forget to adjust all cell references in the formula.
6.
Split complex formulas into simple elements. If you use a complex Excel formula that
includes several different functions, split it into simple elements and verify each function
individually.
And finally, if you've tried all the steps but your conditional formatting rule is still not working
correctly, drop me a line in comments and we will try to fathom it out together :)
In my next article we are going to look into the capabilities of Excel conditional formatting for
dates. See you next week and thanks for reading!
What are Excel sparklines and how to insert them to analyze your data
Do you know what Excel sparklines are and how helpful they can be? Read this article and find
the answers to these questions. You will learn how to insert sparklines in Excel 2010 2013;
change their type, style and color; highlight the most important points and remove sparklines
from cells.
Imagine you are working on a spreadsheet that includes a number of different salespersons and
the amount they sold each month. You want to see how each person's sales are progressing
over time. You can just put this information in one big chart, but it will be hard to pinpoint a trend
for an individual person. Luckily Excel 2010 2013 provides you with a special feature that can
help you give each salesperson a separate mini chart that fits into a single cell. Please
welcome Excel Sparklines!
analyze trends on a more individual basis, and they can really help you manage your worksheet
data.
How to insert sparklines in Excel 2010 2013
Excel sparklines are usually inserted in cells next to the data source. It doesn't matter which of
the three sparklines you want to create, the steps are the same for all types.
1. Select the cells that will serve as the source data for your mini chart.
2. Go to the Sparklines group on the INSERT tab and choose the desired type.
The Create Sparklines dialog box appears on the screen. You see that the selected data range
automatically displays in the Data Range field.
3. Select the cell where you want to place the sparkline. You can just click on the necessary cell
or use the Select Range button to specify the location for your mini chart. The cell reference will
appear in the Location Range field.
4. Click OK.
You see the first sparkline in the cell right next to your source data. If you'd like to apply it for all
other rows of data, you can easily do it by holding and dragging the fill handle.
When you release the mouse button, the sparklines will be inserted in the adjacent cells.
If you have Excel 2013, you can use the Quick Analysis tool to quickly add sparklines to your
data. All you have to do is select the cells in the worksheet and click on the Quick Analysis icon
in the bottom-right corner of the selection. Then switch to the SPARKLINES tab and pick one of
the types.
Note. If you use the Quick Analysis tool for inserting sparklines in Excel 2013, you have a
chance to preview how your data will look with each type. Just hover the pointer over the
respective icon.
Customize Excel mini charts
Once you create sparklines, you may notice that an additional tab appears on the Ribbon. Here
you can find a wide range of tools that'll let you customize your mini charts. So let's make
sparklines stand out a bit.
Show points
Change the sparkline type
Modify the style of a sparkline
Customize Axis settings
Show empty and hidden cells
Before you start modifying your mini charts, I should mention that when you create a range of
sparklines, Excel puts them in a group. As a result it is not necessary to highlight all of the
sparklines when you want to modify them. Change one and you will change them all.
Show points
Since sparklines are so small, the default formatting applied to them by Excel makes it difficult
to identify which values are the highest and lowest points, especially in the line mini chart.
Follow the simple steps described below to see how to emphasize the highs and lows of Excel
sparklines:
1. Click on the cell that contains the sparkline.
2. Go to the Show group on the DESIGN tab.
The sparklines look more readable with the high and low points marked, don't they?
You can also select First Point and Last Point to clearly mark the beginning and the end of the
line. If you check the box next to Markers, every point will be highlighted, which can make your
sparklines look a bit cluttered. Showing Negative Points will be useful in case you have negative
values in your data.
Change the sparkline type
I've already mentioned that there are three different types of sparklines. You can easily switch
between Line, Column and Win/Loss charts. Just click on a sparkline to activate
the DESIGN tab and select the desired type in the Type group.
4. Select the way for a sparkline to show empty cells in the Hidden and Empty Cell
Settings dialog box.
Here you can also check the box next to Show data in hidden rows and columns to display such
values in your sparkline.
The Edit Data option also allows you to change the location and data source for a sparkline
group or a single mini chart.
We examined in depth how you can customize your mini charts and the time has come to know
how to delete sparklines from your Excel worksheet.
Remove sparklines from Excel cells
If you want to get rid of a sparkline, the Delete button won't help with this task. You should use
one of the following methods:
1. Right-click on the mini chart and select Sparklines -> Clear Selected Sparklines from the
context menu.
Note. If you want to delete the entire group, choose the Clear the Selected Sparkline
Groupsoption.
2. Alternatively, select the cell with a sparkline, go to DESIGN -> Group and click the down
arrow next to Clear. You will see the same options as in the right-click menu. Choose the option
you need.
In this article I tried to cover all the bases of creating and customizing sparklines in Excel 2010
2013. Now you know how to insert a sparkline; change its type, style and color; highlight the
most important points and remove sparklines from Excel cells. If I've forgotten to say anything
about this useful feature, let me know in the comments. Thank you for reading!
Excel conditional formatting Icon Sets, Data Bars and Color Scales
The article provides the detailed guidance on how use conditional formatting Icon Sets, Data
Bars and Color Scales in Excel 2013, 2010 and 2007. It will teach you how to extend these
conditional formats beyond their common uses and apply icons based on another cell's value.
Last week we started to explorer various features and capabilities of Conditional formatting in
Excel 2007, 2010 and 2013. If you have not got a change to read that article, you may want to
do this know. If you already know the basics, let's move on and see what format options you
have with regard to Excel's icon sets, color scales and data bars and how you can leverage
them for your projects.
When you click the Conditional Formatting button, a drop-down menu offers you a handful of
pre-defined formatting rules. Let's quickly go through them, one at a time.
Icon sets
Data Bars
Color Scales
Excel conditional formatting Icon Sets
Excel conditional formatting icon sets will help you visually represent your data with arrows,
shapes, check marks, flags, rating starts and other objects.
You apply the icon sets to your data by clicking Conditional Formatting > Icon Sets, and the
icons appear inside selected cells straight away.
In the screenshot above, you can see a table listing the household spendings with a green circle
representing the highest value and red circles lower values. I cannot say that Excel has
interpreted the data in the way I wanted, so let's customize the icon set a bit. To do this,
click More Rules...underneath the icon sets list to bring up the New Formatting Rule dialog.
From here you are able to choose other icons and assign them to different values. I have
decided to stick with the same icons but assign them in a different way:
Tips:
To change the order of icons, click the Reverse Icon Order button.
To hide the cells' values, select the Show Icon Only check box.
To assign icons based on a cell's value instead of specifying a number or percent, type
the cell's address in the Value box or click the selection range icon to select a cell, as shown in
the screenshot below.
icons depending on the values of other cells in a row or based on another cell's value, as
demonstrated in the following examples.
Example 1. Apply an icon set based on other cells in a row (blanks vs. non-blanks)
Suppose, you have a list of products that includes units in stock, delivery and other details.
What you want is to add different icons at the beginning of each row depending on whether
other cells in the same row are blank or non-blank. That is, you will add a check mark in Column
A if all cells in a row are filled in with data, an exclamation mark if some cells are blank, and a
cross icon if all cells in a row are blank. To use an Excel icon set in this way, perform the
following steps:
1. Add an empty column in front of your table (Column A).
2. Copy the following formula across Column A: =COUNTBLANK(B2:F2), where F is the last
column in your table. This formula will count the number of blank cells in each row.
3. Apply the conditional formatting icon set rule to Column A by clicking More Rules..., as
explained above.
4. In the New Formatting Rule dialog, do the following:
Click the Reverse Icon Order button to change the order of icons.
Select the Icon Set Only checkbox.
For the cross icon, set >=5 (where 5 is the number of columns in your table, excluding
the first "Icon" column).
For the exclamation mark icon, set >=1.
Set Type to "Number" for both icons.
1. And again, you start by adding a formula to column A. This time we will use the IF function:
=IF($D2<>"",3,1). The formula says to put 3 in column A if there is any value in the
corresponding cell in column D, otherwise put 1. Naturally, you will need to replace D with the
column you base your formatting on.
2. Select all cells in column A, except for the column header, and create a conditional formatting
icon set rule by clicking Conditional Formatting > Icon sets > More Rules...
3. In the New Formatting Rule dialog, select the following options:
Click the Reverse Icon Order button to change the icons' order.
Select the Icon Set Only checkbox.
For the green flag, set >=3.
For the yellow flag, set >2. As you remember, we do not really want a yellow flag
anywhere, so you set a condition that will never be met, i.e. a value greater than 2 and less than
3.
Set Type to "Number" for both icons.
And here is the result of your effort - the green and red flag icons are added to column A based
on the value in column D.
You apply data bars in Excel in the already familiar way - simply select the cells,
click Conditional Formatting > Data Bars and choose the bar type you want. Once you do
this, the colored bars will be placed inside the selected cells.
As you can see in the screenshot above, Excel conditional formatting data bars work very well
to visually show your household spendings.
If you want to apply your own data bar style, click More Rules... as usual to bring up the Edit
Formatting Rule window, where you choose the desired options:
Place a check in the Show Bar Only checkbox to hide the cells' values and display the
colored bars only.
To select the Minimum and Maximum data types, click the little black arrow next to the
corresponding box. While the Automatic type works fine in most cases, you can also choose
some other data type such as percent, number, formula, etc.
Experiment with Fill color, Border and Bar direction and click OK when you are happy
with theData Bar Preview.
white color scale seems to have worked pretty well too for my household budget:
But if you really want to impress someone and have the time and desire to experiment, try out
theMore Rules... option again and play with the colors a bit. First off, you choose either a 2Color or 3-Color scale, then select your own colors and assign them to the minimum, maximum,
This is how you use Excel's icon sets, color scales and data bars. Very intuitive and userfriendly, aren't they? If you are curious to learn other conditional formatting rule types, the
following tutorials may come in handy:
How to use AutoFill in Excel 2010, 2013 - all fill handle options
This post looks at the AutoFill Excel feature. You will learn how to fill down series of numbers,
dates and other data, create and use custom lists in Excel 2010, 2013 and lower. This article
also lets you make sure you know everything about the fill handle, cause you may be surprised
how powerful this tiny option is.
When you are pressed for time, every single minute counts. So you need to know every way to
automate daily spreadsheet tasks. AutoFill in Excel is a popular feature, and I'm sure most of
you already use it. However, it may be a new fact for you that it's not only about copying values
down a column or getting a series of numbers or dates. It's also about creating custom lists,
double-clicking to populate a large range and much more. If you know where the fill handle is
located, it's high time to find out all the benefits it stores.
Below you see a plan of the post. Just click on the link you find especially interesting to get right
to the point.
o
o
o
o
o
o
o
o
It may be hard to believe that this tiny, almost unnoticeable part of selection gives you numerous
helpful options to use every day.
The scheme is simple. Whenever you need to get a series of values in the adjacent cells, just
click on the Excel fill handle to see a small black cross and drag it vertically or horizontally. As
you release the mouse button, you will see the selected cells filled with the values depending on
the pattern you specify.
One of the most popular questions is how to autofill numbers is Excel. This can also be dates,
times, days of the week, months, years and so on. In addition, Excel's AutoFill will follow any
pattern.
For example, if you need to continue a sequence, just enter the first two values into the starting
cell and grab the fill handle to copy the data across the specified range.
You can also auto-populate any arithmetic progression sequence where the difference between
numbers is constant.
It will even alternate sequences if the selected cells don't relate to each other numerically, like
on the picture below.
And it goes without saying, that you can use the AutoFill option to copy a value across your
range. I think you already know how to make the same value appear in the adjacent cells in
Excel. You just need to enter this number, text, or their combination, and drag it across the cells
using the fill handle.
Presume you have already heard of the features I described above. I still believe, some of them
appeared new to you. So go on reading to learn even more about this popular yet underexplored tool.
All AutoFill Excel options - see the fill handle at its best
Double-click to automatically populate a large range
Suppose you have a huge database with names. You need to assign a serial number to each
name. You can do it in a flash by entering the first two numbers and double-clicking the Excel fill
handle.
Note. This hint will only work if you have values to the left or right of the column you need to fill
as Excel looks at the adjacent column to define the last cell in the range to fill. Please also keep
in mind that it will populate by the longest column in case you have values to the right and to the
left of the empty range you want to fill down.
Excel - Fill down a series of values that contain text
It's not a problem for the AutoFill option to copy across the values that contain both text and
numerical values. Moreover, Excel is quite smart to know that there are only 4 quarters or that
Note. A custom list can only contain text or text with numerical values. If you need it to store
only numbers, please create a list of digits formatted as text.
2. Select the range with your list.
3. In Excel 2003 go to Tools -> Options -> Custom Lists tab.
In Excel 2007 click on the Office button -> Excel options -> Advanced -> scroll down till you see
theEdit Custom Lists button in the General section.
In Excel 2010-2013 click File -> Options -> Advanced -> scroll to the General section to find
the Edit Custom Lists button.
4. Since you already selected the range with your list, you will see its address in the Import list
from cells: field.
5. Press the Import button to see your series in the Custom Lists window.
Use AutoFill Options list to fine tune the way the data is entered
You can adjust the settings with the help of the AutoFill Options list to get the exact results.
There are two ways to get this list.
1. Right-click on the fill handle, drag and drop it. Then you will see a list with options
automatically pop up like on the screenshot below:
2. The other way to get the list is to click on the fill handle, drag and drop it and then click on
theAuto Fill Options icon.
When you click on this icon you get a list with AutoFill options.
This list just repeats some features from the previous part.
Now I will try to briefly describe what it does. Flash Fill instantly studies the data you enter and
the format you use and checks if these data are already in your worksheet. If Flash Fill
recognizes these values and grabs the pattern, it offers you a list based on this mode. You can
click Enter to paste it or ignore the offer. Please see it in action on the picture below:
Flash Fill enables you to format numerous names, dates of birth, and phone numbers in a click
of a mouse. You just enter initial data, which Excel quickly recognizes and uses. I promise that
one of our upcoming articles will give you as many details on this interesting and helpful feature
as possible.
Enable or disable the AutoFill feature in Excel
The fill handle option is turned on in Excel by default. So whenever you select a range you can
see it in the bottom-right corner. In case you need to get Excel AutoFill not working, you can
switch it off by doing the following:
1. Click on File in Excel 2010-2013 or on the Office button in version 2007.
2. Go to Options -> Advanced and untick the checkbox Enable fill handle and cell drag-anddrop.
Note. To prevent replacing the current data when you drag the fill handle, make sure that
theAlert before overwriting cells check box is ticked. If you don't want Excel to display a
message about overwriting non-blank cells, just clear this check box.
Turn Auto Fill Options on or off
If you don't want to display the Auto Fill Options button every time you drag the fill handle, just
turn it off. Similarly, if the button does not show when you use the fill handle, you can turn it on.
1.
Go to File / Office button -> Options -> Advanced and find the Cut, copy and paste
section.
2.
Clear the Show Paste Options buttons when content is pasted check box.
In Microsoft Excel, AutoFill is a feature that allows the user to extend a series of numbers,
dates, or even text to the necessary range of cells. This little option gives you plenty of
possibilities. Use Flash Fill in Excel, autofill dates and numbers, populate numerous cells, and
get custom list values.
That's it! Thank you for reading to the end. Now you know it all, or almost all about the AutoFill
option. Subscribe to our blog to learn even more about this and other helpful Excel features.
Let me know if I didn't manage to cover all the questions and issues you have and I'll be happy
to help you. Just drop me a line in the comments. Be happy and excel in Excel!
Now that you know where the conditional formatting feature is located in Excel, let's move on
and see what format options you have and how you can create your own rules.
How to create Excel conditional formatting rules
To truly leverage the capabilities of conditional format in Excel, you have to learn how to create
various rule types. This will help you make sense of whatever project you are currently working
on.
Conditional formatting rules in Excel define 2 key things:
2. Go to the Home tab > Styles group and click Conditional Formatting. You will see a number
of different formatting rules, including data bars, color scales and icon sets.
3. Since we need to apply conditional formatting only to the numbers less than 0, we
chooseHighlight Cells Rules > Less Than...
Of course, you can go ahead with any other rule type that is more appropriate for your data,
such as:
Highlight duplicates
Format specific dates
4. Enter the value in box in the right-hand part of the window under "Format cells that are LESS
THAN", in our case we type 0. As soon as you have entered the value, Microsoft Excel will
highlight the cells in the selected range that meet your condition.
5. Select the format you want from the drop-down list. You can choose one of the pre-defined
formats or click Custom Format... to set up your own formatting.
5. In the Format Cells window, switch between the Font, Border and Fill tabs to choose the font
style, border style and background color, respectively. On the Font and Fill tabs, you will
immediately see a preview of your custom format.
Tips:
If you want more background or font colors than the standard palette provides, click
the More Colors... button on the Fill or Font tab.
If you want to apply a gradient background color, click the Fill Effects button on
the Fill tab and choose the desired options.
7. Click OK to close the "Less Than" window and check whether the conditional formatting is
correctly applied to your data.
As you can see in the screenshot below, our newly created conditional formatting rule works
right - it shades all the cells with a negative price change.
2. The New Formatting Rule dialog opens and you select the needed rule type. For example,
let's choose "Format only cells that contain" and opt to format the cell values between 60
and 70.
3. Click the Format... button and set up your formatting exactly as we did in the previous
example.
4. Click OK twice to close the open windows and your conditional formatting is done!
This is the simplest example of Excel conditional formatting based on another cell. Other, more
complex scenarios, may require the use of formulas. And you can find several examples of such
formulas along with the step-by-step instructions in this article: How to change a cell color based
another cell's value.
This is how you do conditional formatting in Excel. Hopefully, these very simple rules we have
just created was helpful to understand the general approach.
Apply several conditional formatting rules to one cell / table
When using conditional formatting in Excel, you are not limited to only one rule per cell. You can
apply as many rules as your project's logic requires.
For example, let's create 3 rules for the weather table that will shade temperatures higher than
60 F in yellow, higher than 70 F in orange, and higher than 80 F in red.
You already know how to create Excel conditional format rules of this kind - by
clicking Conditional Formatting > Highlight Cells rules > Greater than. However, for the rules to
work correctly, you also need to set their priority in this way:
1. Click Conditional Formatting > Manage Rules... to bring up the Rules Manager.
2. Click the rule that needs to be applied first to select it, and move it to the top using
the upward arrow. Do the same for the second-in-priority rule.
3. Select the Stop If True check box next to the first 2 rules because you do not want the other
rules to be applied when the first condition is met.
It looks nice, but a bit inundated with graphics. So, our goal is to keep only the red down arrows
to draw attention to the products performing below the average and get rid of all other icons.
Let's see how you can do this:
1. Create a new conditional formatting rule by clicking Conditional formatting > New Rule >
Format only Cells that contain.
2. Now you need to configure the rule in such a way that it gets applied only to the values
greater than the average. You do this by using the =AVERAGE() formula, as shown in the
screenshot below.
Tip. You can always select a range of cells in Excel using the standard range selection icon
or type the range inside the brackets manually. If you opt for the latter, remember to use
absolute cell references with the $ sign.
4. Click Conditional Formatting > Manage Rules... and put a tick into the Stop if True check box
next to the rule you have just created. And... see the result in the screenshot below : )
To fix this, you create one more rule of the "Format only cells that contain" type. In the New
Formatting rule dialog, select Blanks from the drop-down list.
2. In the Conditional Manager Rules Manager dialog, click the rule you want to edit, and then
click the Edit Rule... button.
3. Make the required changes in the Edit Formatting Rule window and click OK to save the
edits.
The Edit Formatting Rule window looks very similar to the New Formatting Rule dialog you used
when creating the rule, so you won't have any difficulties with it.
Tip. If you don't see the rule you want to edit, select This Worksheet from the "Show formatting
rules for" drop-down list to display the list of all rules in your worksheet.
Tip. You can double-click Format Painter if you want to paste the conditional formatting in
several different ranges of cells.
3. To paste the conditional formatting, click on the first cell and drag the paintbrush down to the
last cell in the range you want to format.
Open the Conditional Manager Rules Manager (as you remember, you open it
via Conditional Formatting > Manage Rules...), select the rule and click the Delete Rule button.
Select the range of cells, click Conditional Formatting > Clear Rules and choose one of
the available options.
Now you have basic knowledge of Excel conditional format. In the next article, we will focus on
more advanced features that will help you push conditional formatting in your spreadsheets far
beyond its traditional uses.
And in the meantime, you may want to check out a few more examples of Excel conditional
formatting:
Excel Icon Sets, Data Bars and Color Scales - learn how to extend these conditional
formats beyond their common uses, e.g. apply icons based on another cell's value.
Excel formulas for conditional formatting based on another cell - the tutorial explains how
to use Excel formulas to format individual cells and entire rows based on the values you specify
or based on another cell's value.
How to conditionally format dates in Excel - how to apply Excel conditional formatting to
dates using built-in rules and formulas.
How to change the row color based on a cell's value in Excel - see how you can quickly
shade the entire row based on a numeric or text value of a single cell.
Alternate row colors and column shading in Excel - the article explains how to alternate
row and column shading in Excel using table styles (banded rows and columns) and conditional
formatting.
Change background color based on cell value - two quick ways to change the
background color of cells based on their values in Excel 2013, 2010 and 2007.
How to count and sum cells by color in Excel 2010 and 2013 - see how you can count
cells by color and get the sum of colored cells automatically. The solutions work both for cells
colored manually and with conditional formatting.
How to automatically highlight duplicates in Excel - the article explains how to use
conditional formatting to highlight duplicates values.
Conditional formatting in Excel PivotTables - this tutorial covers some of the differences
in PivotTable formatting in Excel 2010.
Note. The AutoRecover feature only works on Excel workbooks that have been saved at least
once. If you never save a document before a computer crash, the Document Recovery pane
won't show up in Excel.
Luckily, the options to auto save and auto recover files are turned on in Excel by default. If you
are not sure, you can easily check them up.
How to configure the AutoSave (AutoRecover) settings in Excel:
1. Go to the FILE tab and choose Options from the FILE menu
2. Click Save on the left-hand pane of the Excel Options dialog.
3. Make sure that both Save AutoRecover information every X minutes and Keep the last
autosaved version if I close without saving are checked.
4. Click OK.
By default the AutoRecover feature is set to automatically save changes to your workbook every
10 minutes. You can shorten or lengthen this interval as you like. Here you can also change
Excel AutoRecover file location and specify AutoRecover exceptions.
Tip. If you want to be more secure in case of a crash or electricity failure, you should lower the
time interval for saving information. The more frequently the document is saved, the more
versions you have, the more chances to get all the changes back.
Now when Excel is configured to auto save and auto recover your documents, you will easily
restore a file when something goes wrong. Further in this article you'll find out how to recover
new files that you've just created and the ones that you've already saved.
How to recover unsaved Excel files
Suppose you are working on a new document in Excel and the program locks up unexpectedly.
In a few seconds you realize that you didn't save the workbook. Don't panic and discover below
how to recover an unsaved file.
1. Go to FILE -> Open.
3. Scroll down and click on the Recover Unsaved Workbooks button at the bottom of the list.
Note. You can also go to FILE - > Info, open the Manage Workbooks drop-down and
selectRecover Unsaved Workbooks from the menu.
4. When the Open dialog box pops up, just select the necessary file and click Open.
The document will open in Excel and the program will prompt you to save it. Click on the Save
Asbutton in the yellow bar above your worksheet and save the file to the desired location.
Click on the FILE tab and choose Info on the left-hand pane. Next to the Manage
Versions button you'll see all autosaved versions of your document.
Excel automatically saves versions of the workbook at specified intervals, but only if you've
made changes to your spreadsheet between these intervals. The name of each version has a
date, time and the "(autosave)" note. When you click any of them, it will open along with the
most current version of your workbook so that you can compare them and see all the changes.
If the program closed incorrectly, the last autosaved file is labeled with the words (when I
closed without saving).
When you open this file in Excel, you'll get the message above your worksheet. Just click on
theRestore button in the yellow bar to revert to the newer unsaved version of the workbook.
Note. Excel deletes all previously autosaved versions when you close the document. If you
want to look at the previous version again, it is better to create a backup copy of your data.
How to save a backup copy of your workbook
Excel's Auto Backup is a very useful feature that can help you retrieve a previously saved
version of your workbook. Saving a backup copy can protect your work if you accidentally save
changes that you do not want to keep or delete the original file. As a result, you will have the
current saved information in the original workbook and all previously saved information in the
backup copy.
Though this feature is very helpful, it is hard enough to find in Excel 2010 / 2013. So let's do it
together now:
1. Go to FILE - > Save As.
3. When the Save As dialog window pops up, click on the small arrow next to the Tools button at
the bottom of the window.
5. Check the Always create backup box in the General Options dialog and click OK.
Now you can rename your file and choose the desired location to save it. Excel will create a
backup copy of the document in the same folder.
Note. A backed up copy is saved with different .xlk file extension. When you open it, Excel will
ask you to verify that you really want to open this workbook. Just click Yes and you can restore
Another very popular cloud storage service is Dropbox. It keeps snapshots of every change in
your Dropbox folder over the last 30 days. So even if you saved a bad change, or if the file has
been damaged or deleted, you can restore the document to an older version with only a few
clicks. Dropbox doesn't work so closely with Microsoft Office as OneDrive, but it is so simple
that everybody can master it.
Now you know different ways to recover unsaved files and create a backup copy of your
workbook in Excel 2010 and 2013. And I hope you won't push the panic button next time when
your computer crashes or power goes out.
Please follow the below steps closely and you will make a simple Gantt chart in under 3
minutes. We will be using Excel 2010 for this Gantt chart example, but you can simulate Gantt
diagrams in Excel 2007 and Excel 2013 exactly in the same way.
1. Create a project table
You start by entering your project's data in an Excel spreadsheet. List each task is a separate
row and structure your project plan by including the Start date, End date and Duration, i.e. the
number of days required to complete the tasks.
Tip. Only the Start date and Duration columns are really necessary for creating an Excel Gantt
chart. However, if you enter the End Dates too, you can use a simple formula to
calculateDuration, as you can see in the screenshot below.
Select a range of your Start Dates with the column header, it's B1:B11 in our case. Be
sure to select only the cells with data, and not the entire column.
Switch to the Insert tab > Charts group and click Bar.
Under the 2-D Bar section, click Stacked Bar.
As a result, you will have the following Stacked bar added to your worksheet:
Note. Some other Gantt Chart tutorials you can find on the web recommend creating an empty
bar chart first and then populating it with data as explained in the next step. But I think the
above approach is better because Microsoft Excel will add one data series to the chart
automatically, and in this way save you some time.
Step 3. Add Duration data to the chart
Now you need to add one more series to your Excel Gantt chart-to-be.
1. Right-click anywhere within the chart area and choose Select Data from the context menu.
The Select Data Source window will open. As you can see in the screenshot below, Start
Date is already added under Legend Entries (Series). And you need to add Duration there as
well.
2. Click the Add button to select more data (Duration) you want to plot in the Gantt chart.
In the Series name field, type "Duration" or any other name of your choosing.
Alternatively, you can place the mouse cursor into this field and click the column header in your
spreadsheet, the clicked header will be added as the Series name for the Gantt chart.
Click the range selection icon
4. A small Edit Series window will open. Select your project Duration data by clicking on the first
Duration cell (D2 in our case) and dragging the mouse down to the last duration (D11). Make
sure you have not mistakenly highlighted the header or any empty cell.
5. Click the range selection icon again to exit this small window. This will bring you back to the
previous Edit Series window with Series name and Series values filled in, where you click OK.
6. Now you are back at the Select Data Source window with both Start Date and Duration added
under Legend Entries (Series). Simply click OK for the Duration data to be added to your Excel
chart.
2. Make sure the Start Date is selected on the left pane and click the Edit button on the right
pane, under Horizontal (Category) Axis Labels.
3. A small Axis Label window opens and you select your tasks in the same fashion as you
selected Durations in the previous step - click the range selection icon
, then click on the first
task in your table and drag the mouse down to the last task. Remember, the column header
should not be included. When done, exit the window by clicking on the range selection icon
again.
5. Remove the chart labels block by right-clicking it and selecting Delete from the context menu.
At this point your Gantt chart should have task descriptions on the left side and look something
like this:
Step 5. Transform the bar graph into the Excel Gantt chart
What you have now is still a stacked bar chart. You have to add the proper formatting to make it
look more like a Gantt chart. Our goal is to remove the blue bars so that only the orange parts
representing the project's tasks will be visible. In technical terms, we won't really delete the blue
bars, but rather make them transparent and therefore invisible.
1. Click on any blue bar in your Gantt chart to select them all, right-click and choose Format
Data Series from the context menu.
2. The Format Data Series window will show up and you do the following:
Note. You do not need to close the dialog because you will use it again in the next step.
3. As you have probably noticed, the tasks on your Excel Gantt chart are listed in reverse
order. And now we are going to fix this.
Click on the list of tasks in the left-hand part of your Gantt chart to select them. This will display
the Format Axis dialog for you. Select the Categories in reverse order option under Axis
Optionsand then click the Close button to save all the changes.
Your Excel chart is starting to look like a normal Gantt chart, isn't it? For example, my Gantt
diagram looks like this now:
Right-click on the first Start Date in your data table, select Format Cells > General.
Write down the number that you see - this is a numeric representation of the date, in my case
41730. As you probably know, Excel stores dates as numbers based on the number of days
since 1-Jan-1900. Click Cancel because you don't actually want to make any changes here.
Click on any date above the task bars in your Gantt chart. One click will select all the
dates, you right click them and choose Format Axis from the context menu.
Under Axis Options, change Minimum to Fixed and type the number you recorded in
the previous step.
2. Adjust the number of dates on your Gantt chart.
In the same Format Axis window that you used in the previous step, change Major
unit and Minor unit to Fixed too, and then add the numbers you want for the date intervals.
Typically, the shorter your project's timeframe is, the smaller numbers you use. For example, if
you want to show every other date, enter 2 in the Major unit. You can see my settings in the
screenshot below:
Tip. You can play with different settings until you get the result that works best for you. Don't be
afraid to do something wrong because you can always revert to the default settings by switching
back to Auto in Excel 2010 and 2007, or click Reset in Excel 2013.
3. Remove excess white space between the bars.
Compacting the task bars will make your Gantt graph look even better.
Click any of the orange bars to get them all selected, right click and select Format Data
Series.
In the Format Data Series dialog, set Separated to 100% and Gap Width to 0% (or
close to 0%).
And here is the result of our efforts - a simple but nice-looking Excel Gantt chart:
Remember, though your Excel chart simulates a Gantt diagram very closely, it still keeps the
main features of a standard Excel chart:
Your Excel Gantt chart will resize when you add or remove tasks.
You can change a Start date or Duration, the chart will reflect the changes and adjust
automatically.
You can save your Excel Gantt chart as an image or convert to HTML and publish
online.
Tips:
You can design your Excel Gant chart in different ways by changing the fill color, border
color, shadow and even applying the 3-D format. All these options are available in the Format
Data Series window (right-click the bars in the chart area and select Format Data Series from
When you have created an awesome design, it might be a good idea to save your Excel
Gantt chart as a template for future use. To do this, click the chart, switch to the Design tab on
the ribbon and click Save as Template.
The process is very straightforward, you enter your project details in the left-hand table, and as
you type a Gantt Chart is being built in the right-hand part of the screen.
Gantt chart template for Excel, Google Sheets and OpenOffice Calc
Gantt chart template from vertex42.com is a free Gantt chart template that works with Excel
2003, 2007, 2010 and 2013 as well as OpenOffice Calc and Google Sheets. You work with this
template in the same fashion as you do with any normal Excel spreadsheet. Simply enter the
start date and duration for each task and define % in the Complete column. To change the
range of dates displayed in the Gantt chart area, slide the scroll bar.
And finally, one more Gant chart Excel template for your consideration.
Project Manager Gantt Chart template
Project Manager Gantt Chart from professionalexcel.com is also a free project management
Gantt chart template for Excel that can help track your tasks against their allocated time. You
can choose either the standard weekly view or daily for short term projects.
Hopefully, at least one of the above-mentioned Gantt chart Excel templates is well suited for
your needs. If not, you can find plenty more Gantt chart templates on the web.
Now that you are familiar with the main features of the Gantt diagram, you can explore it further
and create your own sophisticated Gantt charts in Excel to amaze your boss and co-workers : )
o
o
o
o
o
o
o
o
Now let's have a closer look at each step. I will be using Microsoft Excel 2013 in this example,
but the steps are absolutely identical in Excel 2010 and very similar in Excel 2007.
Step 1. Prepare the address list in Excel for mail merge
In essence, when you mail merge labels from Excel to Word, the column headers of your Excel
sheet become placeholders in a Word document denoting the mail merge fields. Each
placeholder corresponds to one entry such as first name, last name, salutation, city etc.
Microsoft Word will be pulling out the information from your Excel columns and placing it into the
corresponding merge fields in this way:
So, before starting the Mail Merge, invest some time in setting up your Excel spreadsheet to
ensure it is properly structured for the merging purpose. This will make it easier for you to
arrange, review and print your mailing labels in Word and you save more time in the long run.
Tips:
1.
2.
3.
4.
5.
6.
o
o
Give clear and self-explanatory names to your Excel columns, for example First
Name, Middle Name, Zip Code and so on. In this way you will be able to quickly locate the
right column in a Word mail merge document.
Separate the recipients' information into very small pieces. For example, you'd better
create 3 separate columns for titles, first names and last names rather than a single Name
column.
Make sure your Excel spreadsheet does not contain any blank rows or columns. When
doing a mail merge, empty rows may mislead Microsoft Word and as a result it may merge
only some of the entries believing it has already reached the end of your address list.
To correctly mail merge zip codes and any other numbers, please follow the
recommendations provided in How to format mail merge numbers and dates. This will
ensure that all leading zeros in your postal codes will remain intact.
If you create a mailing list by importing information from a .csv or a .txt file, then use
the Text Import Wizard. You will find the detailed guidance in this article - How to import CSV
to Excel.
To help Microsoft Word locate your address list during mail merge, you can give it a
name in your Excel sheet in this way:
Select the address list in your Excel spreadsheet, including column headers.
Switch to the Formulas tab >Defined Names group > Define Name.
Type a name for the address list in the Name box and click OK. Note that neither
spaces nor hyphens between words are allowed, you can use an underscore _ instead.
Using the Mail Merge Wizard. It provides the step-by-step guidance which may be
helpful for beginners.
Using the Mailings ribbon group. If you are pretty comfortable with the mail merge
feature or prefer working with the ribbon, you can proceed in this way.
Now let's go ahead and configure your main label document. We will be using the step-by-step
wizard in this tutorial to make the learning curve easier.
1. In Microsoft Word 2007, 2010 or 2013, create a new document or open an existing one. The
currently opened document will become your label main document.
Note. If your company already has a package of label sheets from a certain manufacturer, e.g.
Avery, then you need to match the dimensions of your Word mail merge document with the
dimensions of the label sheets you are going to use.
2. Head over to the Mailings tab > Start Mail Merge group and click Step by Step Mail Merge
Wizard.The Mail Merge pane will open in the right part of the screen.
3. Select Labels and click the Next: Starting document link near the bottom of the Mail Merge
pane.
4. Decide where you want to set up your mailing labels - in the current document, some other
existing document or a new document.
If you want to create a new sheet of mailing labels, select the Change document layout radio
button and then click Label options.
Tip. If you do not see the document you want in the Start from existing box, click (More
files...)and you will be able to select any other document from your computer or local network.
5. The Label Options dialog box will open and you select the needed options such as:
Tip. For more information about the selected label package, click the Details... button in the
lower part of the dialog window.
6. When done, click the OK button. Then click Next: Select recipients.
Step 3. Connect the address labels to your Excel mailing list
It's time to connect to your Excel address list to merge the address information with your mailing
labels.
1. Choose to Use an existing list under Select recipients.
2. Click the Browse button and locate the Excel worksheet you want to use.
3. If you have given a name to your address list, as recommended in Step 1. Prepare the
address list in Excel, select it and click OK. Otherwise, select the whole table, you will be able to
refine, sort or filter the recipients to include in the mail merge later.
Those of you who prefer working with the ribbon can connect to an Excel worksheet by
clickingSelect Recipients > Use an Existing List...
Tip. If you wish to make address labels from your Outlook contacts, you do not necessarily
need to import the contacts into Excel. Simply select Choose from Outlook Contacts...instead
of Use an Existing List...
Step 4. Select the recipients to include in the mail merge
The Mail Merge Recipients window will open with all the recipients from your Excel mailing list
selected by default.
To exclude some of the recipients, clear a check box next to their names. When done, click OK.
When you are finished refining the recipients list, click Next: Arrange your labels.
Tips:
To sort the recipient list by a particular column, click the column's heading. The first
click sorts in ascending order, the second - in descending.
To filter the recipient list, click the arrow next to the column heading and choose the
option you want, e.g. blanks or non-blanks. You can also filter the list by some other information
For advanced sorting or filtering, click the arrow next to the column name, and then
select(Advanced...) from the drop-down list.
You can find more options under Refine recipient list section in the lower part of
the Mail Merge Recipients window, e.g. find a recipient, find duplicate items and validate
recipients. The last option is available if you have any validation software installed.
Step 5. Arrange the layout of your address labels
Now you need to define the content of your labels, decide what information to included and
specify how the addresses will appear on each mailing label.
You do this by adding the placeholders to your Word document that correspond to the column
headers in your Excel worksheet. These placeholders are called mail merge fields. When you
perform the label mail merge, the placeholders will be replaced with the information from your
Excel's address list.
To arrange your mailing labels, follow these steps.
1. In the main Word document, click where you want to insert a certain field and then click the
corresponding link on the Mail Merge pane. Typically, for mailing labels you would need only
Another way to add the Address Block is to click the corresponding button on the Mailing tab >
Write and Insert Fields group.
2. The Inset Address Block dialog window will open. Select the desired options, check the
result under the Preview section and click OK.
3. When you are finished with refining your Address Block, click OK, and then Next: Preview
your labels.
How to add missing address elements
It may happen that address elements you see under in the Preview section do not match the
selected address pattern. Typically, this is the case when the column headings of your Excel
sheet differ from the default Word mail merge fields.
For example, you have chosen the following address format for your labels: Salutation, First
name, Last name, Suffix, but the preview shows only the First name and Last name, as you see
in the screenshot below.
In this case, first off verify whether your Excel source file contains all the required data. If it
does, click the Match Fields... button in the lower part of the window to help Word correctly
interpret the elements from your Excel mailing list.
Click the arrow next to the required field and select the right match. For Word to remember your
choice, check the Remember this matching for this set of data... check box.
Click OK and make sure the address elements are displayed correctly. As, you can see in the
next screenshot, the Courtesy Tile does show up now. And since our Excel data source file does
Note. The Address Block will appear simply as AddressBlock in your Word document. When
you print labels from your Excel source file, the chevrons ( ) won't be there, they are used
only to distinguish the mail merge fields in the Word document.
How to make a custom layout of mailing labels
If none of the pre-defined options in the Address Block is suitable for you, you can arrange
acustom layout of your address labels in this way:
1. Click the More items... link on the Mail Merge pane or Insert Merge Field button on
theMailings ribbon group.
2. In the Inset Merge Field dialog, select the desired field and click Insert.
Your custom mail merge fields and the printed mailing labels may look similar to this:
Tips:
To copy the format and layout of the first label to all other labels, click Update all
labels on the Mail Merge pane.
In addition to the mail merge fields, you can add some text or graphics to be printed on
each label, e.g. your company logo or return address.
You can change the format of a particular merge field directly in the Word document,
e.g. display dates or numbers in a different way. Select the needed field, press Shift+F9 to
display the field coding and add a picture switch to the merge field, as explained in Mail merge
with dates, currencies and other numbers.
Step 6. Preview your mailing labels
Well, you are very close to finished : )
1. Click the left or right arrows on the Mail Merge pane or Preview Results ribbon group to see
how your mailing labels will look like when printed.
2. If you want to change the labels' font type, font size, font color or make any other changes,
switch to the Home tab and design the currently previewed label to your liking. The edits will be
automatically applied to all other labels.
3. When you are satisfied with the appearance of your address labels, get back to
the Mailings tab and click Next: Complete the merge.
Tips:
To find and preview a certain label, click Find a recipient... link and type your search
criteria in the Find Entry box.
To make changes in the address list, click the Edit recipient list... link and refine your
mailing list.
Step 7. Print address labels
You are ready to print the address labels from your Excel mailing list.
1. Simply click Print... on the Mail Merge pane or Finish & Merge > Print documents on the
ribbon.
2. Decide whether to print all of your mailing labels, current or selected ones.
Step 8. Save the labels for later use (optional)
If you may want to print the same labels at some point in the future, you have two options:
1. Save the mail merge document connected to the Excel address list.
Click the Save button or press Ctrl+S to save the Word document in the usual way. The mail
merge document will be saved "as-is", connected to your Excel source file. If you make any
changes in the Excel mailing list, your address labels in Word with be updated automatically.
The next time you open the document, Word will ask you whether you want to merge the
information from the Excel data file. Click Yes to merge labels from Excel to Word.
If you click No, Word will break the connection between the document and Excel data file, and
replace the mail merge fields with the information from the first record.
2. Save merged labels as text.
If you want to save the merged labels as usual text, click the Edit individual labels... on the
Mail Merge pane.
In the Merge to New Document dialog box, specify what labels you want to merge. When you
clickOK, Word will open the merged labels in a separate document. You can make any edits
there and then save the file as a usual Word document.
Third party add-ins to print mailing labels from Excel
There exist a number of third-party add-ins purposed for printing address labels. Some of them
are manufactured by label sheets' suppliers and designed especially for formatting and printing
their label packages.
Let's have a quick look at one of such add-ins - Avery Wizard for Microsoft Office. As its name
suggests, this tool is intended for printing Avery labels. The wizard will help you print all kinds of
Avery labels from Excel, Word, Access and Outlook. It supports all versions of Office XP to
Office 2010 and 2013 (32-bit and 64 bit).
You can download a free trial using the above link. To be able to download, you will need to
provide them some basic information such as your name and email address. But this seems to
be the only complexity. The installation goes smoothly and once completed, you will see the
new AVERY tab on your ribbon. Clicking the Avery Wizard button opens a nice looking wizard
One more example of the printing labels software is Brother P-touch Add-In. This tool might help
you print labels using the Ptouch printer. However, the significant limitation of this add-in is that
it currently supports only 32-bit versions of Office 2010 and 2013.
And this is the end of our printing labels tutorial. Thanks a lot to everyone who has read to the
end! If you have any questions or run into problems when printing labels from Excel, do not
hesitate to leave a comment here, we will be happy to help!
o
o
o
o
o
7. Click OK.
The cell content becomes underlined and highlighted in blue. It means that the cell contains the
hyperlink. To check if the link works, just hover the pointer over the underlined text and click on
it to go to the specified location.
Excel HYPERLINK function
Excel has a function named HYPERLINK that you can also use for creating links between
spreadsheets in the workbook. If you are not good at entering Excel formulas immediately in the
Formula bar, do the following:
1. Select the cell to which you want to add a hyperlink.
Now you can see the function name in the Formula bar. Just enter the following two
HYPERLINK function arguments in the dialog window: link_location and friendly_name.
In our case link_location refers to a specific cell in another Excel worksheet
and friendly_name is the jump text to display in the cell.
Note. It's not a must to enter friendly_name. But if you want the hyperlink to look neat and clear,
I'd recommend to do it. If you don't type in friendly_name, the cell will display the link_location
as the jump text.
4. Fill in the Link_location text box.
Tip. If you don't know what address to enter, just use the Select range icon to pick the
destination cell.
When you move to the Friendly_name text box, you see the formula result in the bottom-left
corner of the Function Arguments dialog.
6. Enter Friendly_name that you want to display in the cell.
7. Click OK.
Here you are! Everything is as it should be: the formula is in the Formula bar, the link is in the
cell. Click on the link to check where it follows.
Insert a link by cell drag-and-drop
The quickest way of creating hyperlinks within one workbook is using the drag-and-drop
technique. Let me show you how it works.
As an example, I'll take a workbook of two sheets and create a hyperlink in Sheet 1 to a cell in
Sheet 2.
Note. Make sure that the workbook is saved because this method doesn't work in new
workbooks.
1. Select the hyperlink destination cell in Sheet 2.
2. Point to one of the cell borders and right-click.
4. Press the Alt key and mouse over the Sheet 1 tab.
Having the Alt key pressed automatically takes you to the other sheet. Once Sheet 1 is
activated, you can stop holding the key.
5. Keep dragging to the place where you want to insert a hyperlink.
6. Release the right mouse button for the popup menu to appear.
7. Choose Create Hyperlink Here from the menu.
After you do that, the hyperlink appears in the cell. When you click on it, you'll switch to the
destination cell in Sheet 2.
No doubt that dragging is the fastest way to insert a hyperlink into an Excel worksheet. It
combines several operations into a single action. It takes you less time, but a bit more attention
concentration than two other methods. So it's up to you which way
to go.
Edit a hyperlink
You can edit an existing hyperlink in your workbook by changing its destination, its appearance,
or the text that is used to represent it.
Change link destination
As this article deals with hyperlinks between spreadsheets of the same workbook, the hyperlink
destination in this case is a specific cell from another spreadsheet. If you want to change the
hyperlink destination, you need to modify the cell reference or choose another sheet. You can
do both, if necessary.
The Edit Hyperlink dialog box appears on the screen. You see that it looks the same as
the Insert Hyperlink dialog and has the identical fields and layout.
Note. There are, at least, two more ways to open the Edit Hyperlink dialog. You can press Ctrl +
K or click on Hyperlink in the Links group on the INSERT tab. But don't forget to select the
necessary cell before doing it.
3. Update the information in the appropriate fields of the Edit Hyperlink dialog.
4. Click OK and check where the hyperlink jumps to now.
Note. In case you used Method 2 to add a hyperlink in Excel, you need to edit the formula to
change the hyperlink destination. Select the cell that contains the link, and then place the cursor
in the Formula bar to edit it.
Modify hyperlink format
Most of the time hyperlinks are shown as an underlined text of blue color. If the typical
appearance of hyperlink text seems to you boring and you'd like to stand out of the crowd, go
ahead and read below how to do it:
1. Go to the Styles group on the HOME tab.
2. Open the Cell Styles list.
3. Right-click on Hyperlink to change the appearance of the hyperlink that was not clicked. Or
right-click Followed Hyperlink if the hyperlink was activated.
4. Choose the Modify option from the context menu.
Now you can enjoy a new individual style of the hyperlinks in your workbook. Pay attention that
the changes you made affect all the hyperlinks in the current workbook. You can't change the
appearance of a single hyperlink.
Remove a hyperlink
It will take you a few seconds and no efforts to delete a hyperlink from the worksheet.
1. Right-click the hyperlink you want to remove.
2. Choose the Remove Hyperlink option from the popup menu.
Note. If you happen to forget the keyboard shortcuts, go to the Editing group on the HOME tab and
choose the Go To Special command from the Find & Select drop-down menu. The same dialog
window will appear on the screen.
The Go To Special command allows you to select certain types of cells such as ones containing
formulas, comments, constants, blanks and so on.
4. Select the Blanks radio button and click OK.
Now only the empty cells from the selected range are highlighted and ready for the next step.
The formula (=C3) shows that cell C4 will get the value from cell C3.
5. Press Ctrl + Enter to copy the formula to all the selected cells.
Here you are! Now each selected cell has a reference to the cell over it.
Note. You should remember that all cells that used to be blank contain formulas now. And if you
want to keep your table in order, it's better to change these formulas to values. Otherwise, you'll end
up with a mess while sorting or updating the table. Read our previous blog post and find out two
fastest ways to replace formulas in Excel cells with their values.
2. Click the Fill Blank Cells icon on the Ablebits Utilities tab.
The add-in window displays on the screen with all the selected columns checked.
Done! :)
Besides filling empty cells, this tool will also split merged cells if there are any in your worksheet and
indicate table headers.
Check it out! Download the fully-functional trial version of the Fill Blank Cells add-in and see how it
can save you much time and effort.
Method 1
1. Select the empty cells.
2. Press F2 to enter a value in the active cell.
A few seconds and you have all the empty cells filled with the value you entered.
Method 2
1. Select the range with empty cells.
Whichever way you choose, it will take you a minute to complete your Excel table.
Now you know the tricks for filling in blanks with different values in Excel 2013. I am sure it will be no
sweat for you to do it using a simple formula, Excel's Find & Replace feature or user-friendly Ablebits
add-in.
Convert CSV to Excel: how to import CSV files into Excel spreadsheets
In this article you will find 3 quick ways to convert CSV to Excel. You will also learn how to
import multiple CSV files in a single workbook and how to handle the cases when some data
from a CSV file isn't correctly displayed in an Excel sheet.
Last week we started to investigate the specificities of the comma-separated values format
(CSV)and different ways of converting Excel files to CSV. Today, we are going to do the
opposite - import CSV to Excel.
This article will show you how to open CSV in Excel and import multiple CSV files at a time. We
will also red-flag possible pitfalls along the way and suggest the most effective solutions.
To get Excel to launch the Import Text Wizard, you can either change the file extension from
.csv to .txt before opening the file, or import CSV to Excel as explained further.
How to open a CSV file using Windows Explorer
This is the quickest way to open CSV in Excel. In Windows Explorer, just double click a .csv file
and have it open as a new workbook.
However, this method works only if you have Microsoft Excel set as the default program for
.csv files. If so, then you will see the familiar green Excel icon
displayed next to the .csv
file's name in Windows Explorer.
If Excel is not the default program, you can set it as such in this way:
1. Right-click any .csv file in Windows Explorer, and select Open with... > Choose default
programfrom the context menu.
2. Click Excel (desktop) under Recommended Programs, make sure the "Always use the
selected program to open this kind of file" is selected and click OK.
3. Browse for the csv file you want to import, select it and click the Import button (or simply
double click the .csv file).
4. The Text Import Wizard will appear and you follow its steps.
Before we move further, please have a quick look at the screenshot below that shows the
original CSV file and the desired result in Excel. Hopefully, this will help you better understand
why we choose this or that setting in the example that follows.
Step 1. Choose the file type and the row number to start importing the data. Typically,
you choose Delimited and row 1, respectively. The preview window in the lower part of the
Step 2. In this step, you select a delimiter(s) and text qualifier.Delimiter is the character
that separates values in your .csv file. If your CSV file uses some character other than available
in the pre-defined list, select the Other check box and then type your custom character. In our
example, we specify Tab and Comma since we want each product (separated by tabs) to start
with a new row and the product details such as IDs and sales numbers (separated by commas)
to be imported in separate cells.
Text qualifier is the character that wraps the values in your text file. All text enclosed in the text
qualifier symbols, e.g. "text1, text2" will be imported as one value, even if the text contains a
delimiter you specified.In this example, we have chosen a comma as the delimiter and a
quotation mark as the text qualifier. As the result, all of the numbers with a decimal separator
(which is also a comma in our case!) will be imported in one cell, as you can see in the preview
section below. If we did not specify the quotation mark as the text qualifier, then all the numbers
with decimal separators would be imported into two adjacent cells.
Step 3. If you are happy with the Data preview, then click the Finish button.
Tip. If more than one consecutive comma or other delimiter characters may occur in your CSV
file, then check Treat consecutive delimiters as one check box to prevent empty cells.
4. Choose the destination for the imported data, either an existing or a new worksheet, and
clickOK to finish importing your CSV file to Excel.
Tip. You can click Properties... to set some advanced options such as refresh, layout and
formatting for the imported data.
Note. If your CSV file contains some numerical data or dates, Excel may not convert these
values correctly. To change the format of the imported data, select the problematic column(s) in
Excel, right click and choose Format cells from the context menu.
Convert CSV to Excel: problems and solutions
The CSV format has been around for over 30 years, but notwithstanding its long history it has
never been officially documented. The name CSV (comma-separated values) implies the use of
comma to separate data fields. But this is in theory. De facto, many so-called "CSV" files use
other characters to separate data, such as:
CSV file is incorrectly displayed in Excel (all data is displayed in the 1st column)
Leading zeros are lost when you open a CSV file in Excel
Values are changed to dates when converting CSV to Excel
CSV file is incorrectly displayed in Excel
Symptoms. You are trying to open a .csv file in Excel and all of the data is displayed in the first
column.
Cause. The root of the problem is different separators set in your Windows regional and
language settings and the csv file. In North America and some other countries, the default List
Separator is a comma. While in European countries the comma (,) is reserved as the Decimal
Symbol and the List Separator is set to semicolon (;).
Solutions. There are several possible solutions for this problem, you can quickly look through
the recommendations below and choose the one most suited for your particular task.
1. Specify the right separator directly in the CSV file. Open the CSV file with any text editor
(even the usual Notepad will do) and add the below text in the first line. Note, it should be a
separate line before any data:
The Convert Text to Column wizard, choose the Delimited file type ad click Next. Then select
the needed separator in the next step and click Finish.
3. Change the .csv extension to .txt. Opening a .txt file in Excel will start the Text Import
Wizardand you can choose any delimiter as discussed in importing a csv file to Excel.
4. Open a semicolon delimited CSV file with VBA.
Here is a sample VBA code to open a semicolon delimited CSV file in Excel. Though the code
was written a few years ago for older Excel versions (2000 and 2003), if you are pretty
comfortable with VBA, you won't have problems with updating it or modifying for comma
delimited CSV files.
Note. All of the solutions above change the separator for a given CSV file only. If you'd rather
change the default separator once and for all, proceed with solution 5.
5. Change separators in Region and Language settings.
Click the Start button and open the Control Panel, then click Region and Language > Additional
Settings. The customize Format dialog window will open and you choose a dot (.) as
the Decimal symbol and a coma (,) as the List separator.
Click OK twice to close two dialog windows and you are finished. From now Microsoft Excel will
open and display all CSV (comma separated) files correctly.
Note. Setting new decimal and list separators in Control Panel changes the default separator
characters for all programs on your computer, not only Microsoft Excel.
Leading zeros are lost when opening a CSV file in Excel
Symptom. Your .csv file contains values with leading zeros and those zeros are lost when you
open the CSV file in Excel.
Cause. By default, Microsoft Excel displays SCV files in the General format, which cuts off
leading zeros.
Solution. Instead of opening a .csv file in Excel, run the Text Import Wizard as explained
inImporting CSV to Excel in order to convert CSV to Excel.
In step 3 of the wizard, select the column(s) that contains values with leading zeros and change
the column's format to Text. This will covert your CSV file to Excel keeping all zeros in place.
If you are looking for the opposite, i.e. you want the values in a certain column to be converted
to dates in Excel, then set the format of that column to Date and choose the desired date format
from the drop-down list.
How to import multiple csv files into Excel
As you probably know, Microsoft Excel allows opening several CSV files using
the Open command.
1. You click File > Open and select Text Files (*.prn, *.txt, *.csv) from the drop down list in the
lower right-hand corner.
2. To select adjacent files, click the 1st file, hold down the Shift key, and then click the last file.
Both of the clicked files as well as all the files in-between will get selected.
To select multiple non-adjacent files, hold down the Ctrl and click each .csv file you want to
open.
This method is straightforward and quick and we could call it perfect but for one small thing - it
opens each CSV file as a separate Excel workbook. In practice, switching back and forth
between several Excel files might be quite inconvenient and burdensome.
Now let me show you how you can import multiple CSV files into one Excel workbook, placing
each .csv file on a separate sheet or consolidating all the files in a single spreadsheet.
Importing multiple CSV files in a single Excel workbook
To import several .csv files into one workbook, we are going to use the Consolidate Worksheets
Wizard. This add-in works with all versions of Excel 2013, 2010, 2007 and 2003. The evaluation
version is also available and you can download it right now to follow this example more closely.
The installation will take you just a couple of minutes.
1. Go to the Ablebits Data tab on the Excel ribbon and click the Consolidate Worksheets icon.
2. Select the CSV files you want to import in Excel. If you have the files open, the wizard will
display their names in the dialog window. Otherwise, click the Add files... button in the lower
right-hand corner.
Select the files as you usually do in Windows Explorer (hold Shift to select contiguous files
or Ctrl to select non-contiguous files). The result will look similar to what you see the screenshot
below, and you click Next.
3. Choose how exactly you want to import the selected CSV files to Excel. As you can see in the
screenshot below, you have several choices. Typically, you click the last open that imports all of
the selected CSV files into a single workbook, each file on a separate sheet.
Tip. If you are unsure which option to choose, click the i icon
right to the option in question
and you will see a mockup of the imported files. For example, to consolidate data from multiple
CSV files in a single worksheet, choose the second option - "Copy data from the selected
ranges to one worksheet".
4. In the next step, you decide whether you want to import all the data or values only. When
importing .csv files, you typically go ahead with the default setting "Paste all" and simply
clickNext.
5. The last thing for you to do is to choose the destination for the imported CSV files. And again,
you proceed with the default setting since the New workbook is the only available option.
6. Click Finish, wait for a few seconds and get the desired result - multiple CSV files imported
into one Excel workbook. Fast and painless, isn't it?
As you understand, this was just one of the many possible applications of the Consolidate
Worksheets Wizard. You can find more about this Excel add-in on its homepage.
Hopefully, now you are able to convert any CSV files to Excel with ease. If you have any
questions or have run into any issues, don't hesitate to drop me a comment. And thanks for your
patience everyone who has read this long tutorial to the end! : )
How to convert Excel to CSV and export Excel files to CSV UTF-8 format
Comma-separated values (CSV) is a widely used file format that stores tabular data (numbers
and text) as plain text. Its popularity and viability are due to the fact that a great deal of
programs and applications support csv files, at least as an alternative import / export format.
Moreover, the csv format allows users to glance at the file and immediately diagnose the
problems with data, if any, change the CSV delimiter, quoting rules, etc. All this is possible
because a CSV file is plain text and an average user or even a novice can easily understand it
without any learning curve.
In this article, we will try to investigate quick and efficient ways to export data from Excel to CSV
and learn how to convert Excel to CSV keeping all special characters and foreign symbols
intact. The below methods work for all versions of Excel 2013, 2010 and 2007.
2. In the Save as type box, choose to save your Excel file as CSV (Comma delimited).
Besides CSV (comma delimited), a few other csv formats are available to you:
CSV (comma delimited). This format saves an Excel file as a comma-separated text
that can be used in another Windows program or another version of Windows operating system.
CSV (Macintosh). This format saves your Excel workbook as a comma-separated file
for use on Mac operating system.
CSV (MS-DOS). Saves your Excel file as a comma-separated file for use on the MSDOS operating system.
Unicode Text (*txt). This is a computing industry standard supported by almost all
current operating systems including Windows, Macintosh, Linux and Solaris Unix. It can handle
characters of almost all modern languages and even some ancient ones. So, if you Excel file
contains data in a foreign language, save it in the Unicode Text format first and then convert to
CSV, as explained in Exporting Excel to CSV UTF-8 or UTF-16.
Note. All of the above mentioned formats save only the active Excel sheet.
3. Choose the destination folder where you want to save your Excel file in the CSV format, and
then click Save.
After you click Save, Excel will display two dialogs. Don't worry, these are not error messages
and everything is going right.
4. The first dialog reminds you that only the active Excel spreadsheet will be saved to the CSV
file format. If this is what you are looking for, click OK.
If you need to save the contents of all the sheets your workbook contains, click Cancel and
then save each spreadsheet individually as a separate Excel file (workbook). After that save
each Excel file as CSV.
5. Clicking OK in the first dialog will display a second message informing you that your
worksheet may contain features unsupported by the CSV encoding. This is Okay, so simply
click Yes.
This is how you convert Excel to CSV. The process is quick and straightforward, and you are
unlikely to run into any hurdles along the way.
Export Excel to CSV with UTF-8 or UTF-16 encoding
If your Excel spreadsheets contain some special symbols, foreign characters (tildes, accent
etc.) or hieroglyphs, then converting Excel to CSV in the way described above won't work.
The point is the Save As CSV command distorts any characters other than ASCII (American
Standard Code for Information Interchange). And if your Excel file has smart quotes or long
dashes (e.g. inherited from the original Word document that was copied /pasted to Excel), these
characters would be mangled too.
An easy alternative is saving an Excel workbook as a Unicode(.txt) file and then converting it to
CSV. In this way you will keep all non-ASCII characters undamaged.
Before we proceed further, let me briefly point out the main differences between UTF-8 and
UTF-16 encodings so that you can choose the right format in each particular case.
UTF-8 is a more compact encoding since it uses 1 to 4 bytes for each symbol. Generally, this
format is recommended if ASCII characters are most prevalent in your file because most such
characters are stored in one byte each. Another advantage is that a UTF-8 file containing only
ASCII characters has absolutely the same encoding as an ASCII file.
UTF-16 uses 2 to 4 bytes to store each symbol. However, a UTF-16 file does not always require
more storage than UTF-8. For example, Japanese characters take 3 to 4 bytes in UTF-8 and 2
to 4 bytes in UTF-16. So, you may want to use UTF-16 if your Excel data contains any Asian
characters, including Japanese, Chinese or Korean. A noticeable disadvantage of this format is
that it's not fully compatible with ASCII files and requires some Unicode-aware programs to
display them. Please keep this in mind if you are going to import the resulting file somewhere
outside of Excel.
How to convert Excel to CSV UTF-8
Suppose you have an Excel worksheet with some foreign characters, Japanese names in our
case:
To export this Excel file to CSV keeping all the hieroglyphs intact, follow the steps below:
1. In your Excel worksheet, go to File > Save As.
2. Name the file and choose Unicode Text (*.txt) from the drop-down list next to "Save as type",
and then click Save.
3. Open the unicode .txt file using your preferred text editor, for example Notepad.
Note. Some simple text editors do not fully support all Unicode characters, therefore certain
characters may display as boxes. In most cases this won't affect the resulting file in any way
and you can simply ignore this or use a more advanced text editor such as Notepad++.
4. Since our unicode text file is a tab-delimited file and we want to convert Excel to CSV
(comma-separated) file, we need to replace all tabs with commas.
Note. If you do not need exactly the comma-separated file, just any CSV file that Excel can
understand, you can skip this step because Microsoft Excel handles tab-separated files fine.
If you do want a comma-delimited CSV file, proceed with Notepad in the following way:
Select a tab character, right click it and choose Copy from the context menu, or simply
press CTRL+C as shown in the screenshot below.
Press CTRL+H to open the Replace dialog and paste the copied tab (CTRL+V) in
the Find whatfield. When you do this, the cursor will move rightwards indicating that the tab was
pasted. Type a comma in the Replace with field and click Replace All.
5. Click File > Save As, enter a file name and change the encoding to UTF-8. Then click
the Savebutton.
6. Open the Windows Explorer and change the file extension from .txt to .csv.
An alternative way is to change the .txt extension to .csv directly in Notepad's Save as dialog
and choose All files (*.*) next to Save as type, as shown in the screenshot below.
7. Open the CSV file from Excel by clicking File > Open > Text files (.prn, .txt, .csv) and verify if
the data is Okay.
Note. If your file is intended for use outside of Excel and the UTF-8 format is a must, do not
make any edits in the worksheet, nor should you save a CSV file in Excel, because this may
cause encoding problems. If some of the data does not appear right in Excel, open the file in
Notepad and fix the data there. Remember to save the file in the UTF-8 format again.
How to convert an Excel file to CSV UTF-16
Exporting an Excel file as CSV UTF-16 is much quicker and easier than converting to UTF-8.
This is because Excel automatically employs the UTF-16 format when saving a file as Unicode
(.txt).
So, what you do is simply click File > Save As in Excel, select the Unicode Text (*.txt) file
format, and then change the file extension to .csv in Windows Explorer. Done!
If you need a comma-separated or semicolon-separated CSV file, replace all tabs with commas
or semicolons, respectively, in a Notepad or any other text editor of your choosing (see Step 6
above for full details).
Tip. If you have a relatively small Excel file, then you can simply copy / paste the data to a
Google sheet to save time.
5. Go to the File menu > Download as, select Comma separated values (CSV, current
sheet) and save the SCV file to your computer.
Finally, open the CSV file in some text editor to make sure all of the characters are saved
correctly. Regrettably, the CSV files converted in this way do not always correctly display in
Excel. Kudos to Google and shame to Microsoft : )
Save .xlsx to .xls and then convert to .csv file
This method of converting Excel to CSV hardly needs any further explanations because the
heading says it all.
I have come across this solution on one of Excel forums, cannot remember now which exactly.
To be honest, this method has never worked for me, but many users reported that special
characters, which got lost when saving .xlsx directly to .csv, were preserved if to save a .xlsx file
to .xls first, and then save .xls as .csv in Excel, as explained in How to convert Excel to CSV.
Anyway, you can try this method of exporting Excel to CSV on your side and if it works, this can
be a real time-saver.
Save Excel as CSV using OpenOffice
OpenOffice, an open-source suite of applications, includes a spreadsheet application
named Calcthat is really good at exporting Excel data to CSV format. In fact, it provides more
options to convert spreadsheets to CSV files (encodings, delimiters etc.) than Excel and Google
Sheets combined.
You simply open your Excel file with OpenOffic Calc, click File > Save as and save the file
as Text CSV (.scv) type.
In the next step, you will have a choice of various Character sets (encodings) and Field
delimiters. Naturally, you select Unicode (UTF-8) and comma if your goal is a CVS UTF-8 file
(or whatever encoding and separator character you need) and click OK. Typically, the Text
delimiter will remain the default quotation mark (").
You can also use another application of the same kind, LibreOffice, to perform fast and painless
Excel to CSV conversions. It would be really nice if Microsoft Excel provided similar options with
regard to CSV encodings, agree?
These are the ways of converting Excel to CSV I am aware of. If you know other more efficient
methods to export an Excel file to CSV, please do share in comments. Thank you for reading!
Whether you decide to show gridlines in your worksheet or hide them, go ahead and find below
different ways to fulfil these tasks in Excel 2010 and 2013.
Note: If you'd like to make Excel show gridlines in two or more sheets, hold down the Ctrlkey
and click the necessary sheet tabs at the bottom of the Excel window. Now any changes will be
applied to every selected worksheet.
When you are done with the selection, just navigate to the VIEW tab on the Ribbon and check
theGridlines box in the Show group.
Alternatively, you can go to the Sheet Options group on the PAGE LAYOUT tab and select
the Viewcheckbox under Gridlines.
Whichever option you choose gridlines will instantly appear in all the selected worksheets.
Note: If you want to hide gridlines in the entire spreadsheet, just uncheck
the Gridlines or Viewoptions.
Show / hide gridlines in Excel by changing the fill color
One more way to display / remove gridlines in your spreadsheet is to use the Fill Color feature.
Excel will hide gridlines if the background is white. If the cells have no fill, gridlines will be
visible. You can apply this method for an entire worksheet as well as for a specific range. Let's
see how it works.
1. Select the necessary range or the entire spreadsheet.
Tip: The easiest way to highlight the whole worksheet is to click on the Select All button in the
top-left corner of the sheet.
You can also use the Ctrl + A keyboard shortcut to select all the cells in the spreadsheet. You'll
need to press the key combination twice or three times if your data is organized as Table.
2. Go to the Font group on the HOME tab and open the Fill Color drop-down list.
3. Choose the white color from the list to remove gridlines.
Note: If you want to show lines in Excel, pick the No Fill option.
As you can see in the screenshot above, applying the white background will give an effect of
hidden gridlines in your worksheet.
Make Excel hide gridlines only in specific cells
In case you want Excel to hide gridlines only in a certain block of cells, you can use the white
cells background or apply white borders. Since you already know how to change the
background color, let me show you how to remove gridlines by coloring the borders.
1. Select the range where you want to remove lines.
2. Right-click on the selection and choose Format Cells from the context menu.
Note: You can also use the Ctrl + 1 keyboard shortcut to display the Format Cells dialog.
3. Make sure that you are on the Border tab in the Format Cells window.
4. Choose the white color and press the Outline and Inside buttons under Presets.
Note: To bring gridlines back to the block of cells, choose None under Presets in the Format
Cellsdialog window.
Remove gridlines by changing their color
There is one more way to make Excel hide gridlines. If you change the default gridline color into
white, gridlines will disappear in the whole worksheet. If you're interested in this method, feel
free to find out how to change the default gridline color and print gridlines in Excel 2010 / 2013.
You see there are different ways to show and hide gridlines in Excel. Just choose the one that
will work best for you. If you know any other methods of showing and removing cell lines, you
are welcome to share them with me and other users! :)
It's that simple! Now you can leisurely keep working on your worksheet.
If you want to make sure that the document will be printed with gridlines, just navigate to FILE
-> Print or press the Ctrl + P keyboard shortcut. In the Print Preview pane you will see how your
worksheet will look like on the printouts.
1. Click on the Page Setup link under the Print Settings list.
4. Click OK.
You will immediately see your spreadsheet with lines in the Print Preview pane.
Note:Excel does not print gridlines around empty cells in a worksheet. If you want to include
blank rows and columns into printing as well, just use the Print Area icon to set the range.
>
3. Select the Advanced category on the left pane of the Excel Options window.
4. Scroll down to Display options for this worksheet.
5. Pick the sheet from the drop-down list where you want to change the grid lines color.
You will see that the cell boundaries are accurately outlined by colored lines. They will help you
read information on the paper copy of your spreadsheet, keeping rows and columns with data
visually organized.
Alongside with grid lines, you can also improve readability of your Excel document by printing
row and column headers on every page.
Now you know how to print gridlines in Excel 2010 2013 and change the default gridline color.
I hope you'll find these simple tricks helpful, and your colleagues will appreciate your friendly
way of printing out data.
To convert your Excel data to HTML, perform the following steps. These instructions apply to all
"ribboned" versions of Excel 2013, 2010 and 2007:
Web Page (.htm; .html). This will save your workbook or the selection to a web page and
create a supporting folder that will store all of the page's supporting files such as images, bullets
and background textures.
Single File Web Page (.mht; .mhl). This will save your workbook or the selection to a
single file with supporting files embedded into the web page.
3. If you selected a range of cells, a table or a chart before clicking Save as, then select
theSelection radio button, click Save and you are close to finished.
If you have not selected anything yet, continue with the following steps.
To save the entire workbook, including all the worksheets, graphics and tabs for
navigating between sheets, select Entire Workbook.
To save the current worksheet, choose Selection: Sheet. In the next step you will be
given a choice whether to publish the whole worksheet or some of the items.
You can also set a title for your web-page now by clicking the Change Title... button in the righthand part of the dialog window. You will also be able to set or change it later, as described in
step 6 below.
4. Click the Publish button and this will open the Publish as Web Page dialog window. Let's
briefly go through each of the available options, from top to bottom.
5. Items to publish. Here you choose what portion(s) of your Excel workbook you want to
export to a web-page.
In the drop-down list next to Choose, you have the following choices:
Entire workbook. The whole workbook will be published, including all of the worksheets
and tabs to navigate between sheets.
Entire worksheet or certain items on a worksheet, such as pivot tables, charts, filtered
ranges and External data ranges. You select "Items on SheetName", and then choose either
Ranges of cells. Select Range of cells in the drop-down list and then click the range
selection icon to select the cells you want to publish.
Previously published items. Select this option if you want to republish a worksheet or
items you have already published. If you'd rather not republish a certain item, select the item in
the list and click the Remove button.
6. Title of the web-page. To add a title that will be displayed in the title bar of the browser, click
the Change button next to Title: and type in the title you want.
7. Click the Browse button next to File name and choose the hard drive, folder, web folder, web
server, HTTP site, or FTP location where you want to save your web page.
Tips: If you are converting an Excel workbook to an HML file for the first time, it makes sense to
save the web page onto your local hard drive first so that you can make the needed corrections
before publishing the page on the web or your local network.
You can also choose to export your Excel file to an existing web page provided that you have
permissions to modify it. In this case, upon clicking the Publish button, you will see a message
prompting you to choose whether you want to overwrite the content of the existing web-page or
append your data to the end of the web page. If the former, click Replace; if the latter, clickAdd
to file.
8. Select "AutoRepublish every time this workbook is saved" if you want to have the
workbook or selected items automatically republished after each saving of the workbook. I'll
explain theAutoRepublish feature in more detail further on in the article.
9. Select the "Open published Web page in browser" check box in case you want to view the
web page right after saving.
10. Click the Publish button and you are done!
As you can see in the screenshot below, our Excel table looks fairly nice online, though the
design of the original Excel file is a bit distorted.
Note: The HTML code created by Excel is not very clean and if you are converting a large
spreadsheet with a sophisticated design, it may be a good idea to use some HTML editor to
clean up the code before publishing so that it will load more quickly onto your web site.
5 things you should be aware of when converting an Excel file to HTML
When you use Excel's Save as Web Page function, it is important that you understand how its
main features work in order to avoid most typical mistakes and prevent common error
messages. This section provides a quick overview of the options you should pay special
attention to when exporting your Excel spreadsheet to HTML.
1. Supporting files and hyperlinks
As you know, web pages often contain images and other supporting files as well as hyperlinks
to other web-sites. When you convert an Excel file to a web page, Excel automatically manages
the related files and hyperlinks for you and saves them to the supporting files folder,
namedWorkbookName_files.
When you save the supporting files such as bullets, graphics and background textures to the
same web server, Excel maintains all the links as relative links. A relative link (URL) points to a
file within the same web site; it specifies the file name or a root folder only rather than the full
website address (e.g. href="/images/001.png"). When you delete any item saved as a relative
link, Microsoft Excel automatically removes the corresponding file from the supporting folder.
So, the main rule is to always keep the web page and supporting files in the same location,
otherwise your web page may no longer display properly. If you move or copy your web page to
another location, be sure to move the supporting folder to the same location to maintain the
links. If you re-save the web page to another location, Microsoft Excel will copy the supporting
folder for you automatically.
When you save your web pages to different locations or if your Excel files contain hyperlinks to
external web sites, absolute links are created. An absolute link specifies the full path to a file or
a web-page that can be accessed from anywhere, e.g. www.yourdomain/products/product1.htm.
2. Making changes and re-saving a Web page
In theory, you can save your Excel workbook as a Web page, then open the resulting web page
in Excel, make edits and re-save the file. However, in this case some Excel features will no
longer be working. For example, any charts contained in your workbook will become separate
images and you won't be able to modify them in Excel as usual.
So, the best practice is to maintain your original Excel workbook up to date, make changes in
the workbook, always save it as a workbook (.xlsx) first and then save as a Web page file (.htm
or .html).
3. AutoRepublishing a Web page
If you selected the AutoRepublish checkbox in the Publish As Web Page dialog discussed in
step 8 above, then your web page will get updated automatically every time you save your Excel
workbook. This is a really helpful option that lets you always maintain an up-to-date online copy
of your Excel table.
If you have turned on the AutoRepublish feature, a message will appear each time you save the
workbook asking you to confirm whether you want to enable or disable AutoRepublish. If you
want to have your Excel spreadsheet republished automatically, then naturally
select Enable...and click OK.
However, there are some circumstances when you may not want to republish your spreadsheet
or selected items automatically, e.g. if your Excel file contains confidential info or has been
edited by someone who is not a trusted source. In this case, you can make AutoRepublish
temporarily or permanently unavailable.
To temporarily disable AutoRepublish, select the first option "Disable the AutoRepublish
feature while this workbook is open" in the above-mentioned message. This will turn off autorepublishing for the current session, but it will be enabled again the next time you open the
workbook.
To permanently disable AutoRepublish for all or selected items, open your Excel workbook,
choose to save it as Web page and then click the Publish button. In the Choose list, under
"Items to publish", select the item you do not want to republish and click the Remove button.
Regrettably, a couple of very useful and popular Excel features are not supported when you
convert your Excel worksheets to HTML:
Cell's content (text) is truncated or not completely displayed. To prevent text from
being cut off, you can either turn off the wrapped text option, or shorten the text, or widen the
column width, also make sure the text is aligned to the left.
The items you save to an existing Web page always appear at the bottom of the
page while you want them at the top or in the middle of the page. This is a normal behavior
when you choose to save your Excel file as an existing web page. To move your Excel data to
another position, either edit the resulting web-page in some HTML editor or rearrange the items
in your Excel workbook and save it as a web page anew.
Links on the web page are broken. The most obvious reason is that you have moved
either the web page or the supporting folder to another location. See supporting files and
hyperlinksfor more details.
A red cross (X) is displayed on the Web page. A red X indicates a missing image or
other graphic. It may get broken for the same reason as hyperlinks. Just make sure you always
keep the web-page and supporting folder in the same location.
Excel to HTML converters
If you often need to export your Excel tables to HTML, the standard Excel means we have just
covered may seem a bit too long way. A faster method is to use an Excel to HTML converter,
either online or desktop. There are a handful of online converters on the Internet both free and
paid and we are going to try a few right now.
TABLEIZER - free and simple Excel to HTML online converter
This one-click online converter handles simple Excel tables with ease. All you need to do is to
paste the contents of your Excel table to the window and click the Tableize It! button. Some
basic formatting options such as font size, font type, header color, and even CSS styles are
available.
After that you just copy the HTML code generated by the Tableizer converter and paste it to your
webpage. The best thing when using this tool (apart from speed, simplicity and no cost : ) is the
preview window that shows how your Excel table is going to look like online.
However, the formatting of your original Excel table will not be automatically converted to HTML
as you see in the screenshot below, which is a very significant drawback in my judgment.
If you are interested to try this online converter, you can find it
here:http://tableizer.journalistopia.com/
Another free Excel to HTML converter is available at pressbin.com, though it yields to Tableizer
in many respects - no format options, no CSS and even no preview.
Advanced Excel to HTML converter (paid)
Unlike the two previous tools, the SpreadsheetConverter works as an Excel add-in and
requires installation. I've downloaded a trial version (as you understand from the heading, this is
commercial software) to see if it is in any respect better than either free online converter we've
just experimented with.
I must say I was impressed! The conversion process is as easy as clicking the Convert button
on the Excel ribbon.
And here is the result - as you can see, the Excel table exported to a web-page looks very close
to the source data:
For the sake of experiment, I've also tried to convert a more complex workbook containing
several sheets, a pivot table and a chart (the one we saved as web page in Excel in the first part
of the article) but to my disappointment the result was much inferior to what Microsoft Excel
produced. Maybe this is just because of the trial version's limitations.
Anyway, if you are willing to explore all the capabilities of this Excel to HTML converter, you can
download an evaluation version of the SpreadsheetConverter add-in here.
Excel web viewers
If you are not happy with the performance of Excel to HTML converters and are looking for
alternatives, some web viewer may work a treat. Below you will find a quick overview of several
Excel Web Viewers so that you can get a feel of what they are capable of.
Zoho Sheet online viewer allows viewing Excel spreadsheets online by either uploading a file or
entering the URL. It also provide an option to create and manage Excel spreadsheets online.
This is probably one of the most powerful free online Excel viewers. It supports some basic
formulas, formats and conditional formatting, allows you to sort and filter the data and convert it
to a number of popular formats such as .xlsx, .xls, .ods, .csv, .pdf, .html and others, as you see
in the screenshot below.
Its main weakness is that it does not keep the format of the original Excel file. I also have to
admit that Zoho Sheet web viewer was not able to cope with a sophisticated spreadsheet
containing a custom table style, complex formulas and a pivot table.
You can also check out a couple of other Excel web viewers, e.g. XML Grid.net and EditGrid,
but these are much inferior in terms of features and supported formats.
Well, we have explored a few options to convert Excel spreadsheets to HTML. Hopefully, this
will help you choose the technique in accordance with your priorities - speed, cost or quality?
The choice is always yours : )
In the next article we are going to continue this topic and investigate how you can move your
Excel data online using Excel Web App and Excel Online.
Alternating row color and column shading in Excel (banded rows and columns)
This tutorial explains how you can alternate row colors in Excel to automatically highlight every
other row or column in your worksheets. You will also learn how to apply Excel banded rows
and columns and find a few smart formulas to alternate row shading based on a value change.
It is a common practice to add shading to alternate rows in an Excel worksheet to make it easier
to read. While it is a relatively easy job to highlight rows of data manually in a small table, it
could be an arduous task in larger ones. A better way is to have row or column colors alternated
automatically and this article is going to show you how you can quickly do this.
o
o
o
o
3. Done! The odd and even rows in your table are shaded with different colors. The best thing is
that automatic banding will continue as you sort, delete or add new rows to your table.
If you'd rather have alternate row shading only, without the table functionality, you can easily
convert the table back to a usual range. To do this, select any cell within your table, right click
and choose Convert to Range from the context menu.
Note: If you opt to convert a table to range, you won't get the automatic color banding when you
add new rows to the range. Another disadvantage is that as you sort the data, i.e. move certain
cells or entire rows within the range, your color bands will travel with the original rows and your
nice zebra stripe pattern will get distorted.
As you can see, converting a range to table is a very easy and quick way of highlighting
alternate rows in Excel. But what if you want a bit more?
How to choose your own colors of row stripes
If you are not happy with the default blue and white pattern of an Excel table, you have plenty
more patterns and colors to choose from. Just select your table or any cell within the table,
switch to the Design tab > Table Styles group and select the colors of your liking.
You can use the arrow buttons to scroll through the available table styles or click
the More button
to view them all. When you hover the mouse cursor over any style, it is
immediately reflected to your table and you can see how your banded rows would look like.
6. Apply the newly created style to your table by selecting it from the Table Styles gallery. Your
custom styles are always available at the top of the gallery under Custom.
Note: Custom table styles are stored only in the current workbook and therefore are not
available in your other workbooks. To use your custom table style as the default table style in
the current workbook, select the "Set as default table style for this document" check box
when creating or modifying the style.
If you are not happy with the style you created, you can easily modify it by right-clicking your
custom style in the Styles Gallery and choosing Modify from the context menu. And here you
have plenty of room for your creativity! You can set any Font, Border, and Fill styles on the
corresponding tabs, even choose gradient stripe colors, as you see in the screenshot below : )
As you see, Excel's predefined table styles provide a wealth of features to alternate color rows
in your worksheets and create custom banded rows styles. I believe they will suffice in many
situations, though if you want something special, e.g. shading entire rows based on a change of
value, then you will need to use conditional formatting.
Alternate row shading using Excel conditional formatting
It goes without saying that conditional formatting is a bit trickier that Excel table styles we have
just discussed. But it has one undisputable benefit - it allows more room for your imagination
and lets you zebra stripe your worksheet exactly as you want it is each particular case. Further
on in this article, you will find a few examples of Excel formulas for alternating row colors:
2. Switch to the Home tab > Styles group and click Conditional Formatting > New Rule...
3. In the New Formatting Rule window, choose "Use formula to determine which cells to
format" option and enter this formula: =MOD(ROW(),2)=0
4. Then click the Format button, switch to the Fill tab and select the background color that you
want to use for the banded rows.
At this point, the selected color will appear under Sample. If you are happy with the color,
click OK.
5. This will bring you back to the New Formatting Rule window, and you click OK one more time
to apply to color to every other of the selected rows.
And here's how the result looks like in my Excel 2013:
If you'd rather have 2 different colors instead of white lines, then create a second rule using this
formula: =MOD(ROW(),2)=1
And now you have odd and even rows highlighted with different colours:
That was pretty easy, wasn't it? And now I'd like to briefly explain the syntax of the MOD function
because we are going to use it in other a bit more complex examples.
The MOD function - MOD(number, divisor) - returns the remainder rounded to the nearest
integer after the number is divided by the divisor.
For example, =MOD(4,2) returns 0, because 4 is divided by 2 evenly (without remainder).
Now, let's see what exactly our MOD function, one that we've used in the above example, does.
As you remember we used a combination of the MOD and ROW functions: =MOD(ROW(),2)
The syntax is simple and straightforward: the ROW function returns the row number, then the
MOD function divides it by 2 and returns the remainder rounded to the integer. When applied to
our table, the formula returns the following results:
Row No.
Formula
Result
Row 2
=MOD(2,2)
Row 3
=MOD(3,2)
Row 4
=MOD(4,2)
Row 5
=MOD(5,2)
Do you see the pattern? It's always 0 for even rows and 1 for odd rows. And then we create
the conditional formatting rules telling Excel to shade odd rows (where the MOD function returns
0) in one color and even rows (that have 1) in another color.
Now that you know the basics, let's look into more sophisticated examples.
How to alternate groups of rows with different colors
You can use the following formulas to shade a fixed number of rows, regardless of their content:
Odd row shading, i.e. highlight the 1st group and every other group:
=MOD(ROW()-RowNum,N*2)+1<=N
Even row shading, i.e. highlight the 2nd group and all even groups:
=MOD(ROW()-RowNum,N*2)>=N
Where RowNum is a reference to your first cell with data and N is the number of rows in each
banded group.
Tip: If you want to highlight both even and odd groups, then simply create 2 conditional
formatting rules with both of the above formulas.
You can find a few examples of formula usage and the resulting color banding in the following
table.
To color every 2
rows, starting from
the 1stgroupThe data
starts in row 2.
=MOD(ROW()2,4)+1<=2
To color every 2
rows, starting from
the 2ndgroupThe data
starts in row 2.
=MOD(ROW()-2,4)>=2
To color every 3
rows, starting from
the 2ndgroupThe data
starts in row 3.
=MOD(ROW()-3,6)>=3
To alternate row shading based on value, you'd need a bit more complex formula and an
additional column:
1. Create an additional column over the right side of your worksheet, say column F. You will be
able to hide this column later.
2. Enter the following formula in cell F2 (assuming that row 2 is your first row with data) and
then copy it across the entire column:
=MOD(IF(ROW()=2,0,IF(A2=A1,F1, F1+1)), 2)
The formula will fill down column F with blocks of 0 and 1, every new block staring with the
Product name change.
3. And finally, create a conditional formatting rule using the formula =$F2=1. You can add a
second rule =$F2=0 if you want a second color to alternate blocks of rows, as shown in the
screenshot:
2. Then switch to the Design tab, remove a tick from Banded rows and select Banded
columnsinstead.
3. Voila! Your columns are shaded with the default table colors.
In case you'd like prettier colors, you are free to choose any other pattern from the Table Styles
Gallery.
If you want to shade a different number of columns in each stripe, then create a duplicate of
an existing table style of your choosing, exactly as described here. The only difference is that
you choose "First Colum Stripe" and "Second Colum Stripe" instead of the corresponding
row stripes.
And this is how your custom column bands may look like in Excel:
To color every
other column
=MOD(COLUMN(),2)=0
and/or
=MOD(COLUMN(),2)=1
To color every 2
columns, starting
from the 1st group
=MOD(COLUMN()1,4)+1<=2
To shade columns
with 3 different
colors
=MOD(COLUMN()
+3,3)=1
=MOD(COLUMN()
+3,3)=2
=MOD(COLUMN()
+3,3)=0
Hopefully, now you won't have any problems with applying color banding in Excel to make your
worksheets handsome and more readable. If you want to alternate row or column colors in
some other way, don't hesitate to leave me a comment and we will figure this out together.
Thank you for reading!
1. Select the rows and columns you want to switch. If you want to rotate the entire table, i.e. all
the cells with data in a spreadsheet, press Ctrl+Home and then Ctrl+Shift+End.
2. Copy the selected cells either by right clicking the selection and choosing Copy from the
context menu, or pressing Ctrl+C, or clicking the Copy button on the Home tab > Clipboard
group.
3. Select the first cell of the destination range into which you want to copy the transposed data.
Note: It's important that you select a cell that falls outside of the range containing your original
data, so that the copy areas and paste areas do not overlap. For example, if you currently have
4 columns and 10 rows, once you transpose the table it will be 10 columns and 4 rows.
4. Paste the copied data using Paste Special > Transpose feature. You can open the Paste
Specialdialog in 3 ways:
On the Home tab > Clipboard group, click the little black arrow below the Paste button,
and selectTranspose.
Right click the destination cell and choose Paste Special from the context menu, then
selectTranspose.
And finally, the fastest way is to press CTRL+ALT+V, select Transpose and click OK.
Note: If you transpose cells that contain formulas, make sure that absolute references (with $
sign) are used in all cells. This is necessary because your formulas will also be transposed and
cell references automatically adjusted.
As, you have just seen, Excel's Transpose feature lets you perform row to column (or column to
row) transformations literally in a few seconds. I believe this solution is a really good way to go if
transposing a table is a one-time process. This method also copies the formatting of your
original data, which adds one more argument in its favor.
However, the above mentioned approach has two drawbacks that prevent it from being called
a perfect solution for transposing data in Excel:
The transpose option is not available when copying/pasting a fully-functional Excel table,
as opposed to a simple range. In this case, you need either to copy the table without column
headers, or convert it to range (right click any cell in the table and choose Table > Convert to
Range from the context menu).
A more serious limitation of this method is that it creates a copy of your original data and
whenever the source data change, you'd need to repeat the process and rotate the table anew.
No one would want to waste their precious time on converting the same rows and columns over
and over again, right?
How to transpose a table linked to the original data
Let's see how you can switch rows to columns in Excel using the familiar copy / paste technique
that would link the transposed cells to the original data. The best thing with using this approach
is that whenever you change the data in the source table, the transposed table will reflect the
changes and update accordingly.
1. Copy the rows you want to convert to columns (or columns to be converted to rows).
2. Select an empty cell in the same or another worksheet.
3. Open the Paste Special dialog, as explained in the previous solution and select Paste Link in
the lower left-hand corner of the dialog window.
4. Select this new data and open Excel's Find and Replace dialog (you can press CTRL+H to
get to the Replace tab straight away).
5. Replace all "=" characters with "xxx" (you can actually replace it with any other character(s)
that do not exist anywhere in your real data).
This will turn your table into something a bit scary, as you see in the screenshot below, but don't
be afraid, just 2 more steps, and you'll achieve the desired result.
6. Copy the table with "xxx" values, and then apply Paste Special > Transpose to convert the
columns to rows, or rows to columns, depending on your needs.
7. And finally, open the Find and Replace dialog one more time to reverse the change, i.e.
replace all "xxx" with "=" to restore the links to the original cells. Done!
This is a quick, stress-free and elegant solution, isn't it? The only drawback of this approach is
that the original table's formatting gets lost in the process and you will need to restore it
manually (I'll show you a quick way to do this further on in this tutorial).
Transpose data in Excel using formulas
If you are not looking for easy ways, then you can utilize formulas to convert columns to rows in
your Excel tables and vice versa.
First off, you need to determine the exact number of rows and columns in your table. Our
sample table has 7 columns and 6 rows, including headings. Keeping these numbers in mind,
let's start rotating rows to columns.
1. Count the cells you want to transpose. In our case it is 7 columns and 6 rows.
2. Select an empty range of cells. Since the TRANSPOSE function shifts the vertical and
horizontal orientation of a selected range, you need to select the same number of rows and
columns as your source table has columns and rows, respectively. In our example, we are
selecting 6 columns and 7 rows.
3. Press F2 to enter the edit mode.
4. Write the TRANSPOSE function and enter the data range you want to transpose in
brackets:=TRANSPOSE(array). In our case, we enter =TRANSPOSE($A$1:$G$6).
Note: You always need to use absolute references in the Transpose function.
5. Press CTRL+SHIFT+ENTER.
Note: You do need to hit Ctrl+Shift+Enter because this is an array formula, pressing
simplyEnter won't work.
Done! Our data is transposed and we have 7 columns changed into 6 columns, exactly as we
wanted:
The original table formatting is not saved in the converted table, as you see in the
screenshot above.
If there are any empty cells in the sores table, the transposed cells will contain 0 instead.
You cannot edit any cells in the converted table because the TRANSPOSE function is
very much dependent on the source data. If you try to change some cell's value, you will end up
having "You cannot change part of an array" error.
Wrapping up, whatever good and easy-to-use the TRANSPOSE function is, it certainly lacks
flexibility and therefore may not be the best way to go in many situations.
Row to column / column to row transformation using INDIRECT function
This method of converting column to row and vice versa is pretty much similar to the previous
one. Its main benefit over the Transpose function is that it allows making changes in the
transposed table, at the same time keeping the connection to the original table.
We will use a small table in this example so that you can focus on the transpose process rather
than on the data because we will be using a combination of INDIRECT and ADDRESS
functions, which is a little bit tricky.
Suppose, you have data in 4 columns (A - D) and 5 rows (1 - 5):
1. Enter the below formula in the left most cell of the destination range, let's say A7, and press
theEnter key:
=INDIRECT(ADDRESS(COLUMN(A1),ROW(A1)))
If your data starts in some row other than 1 and column other than A, you will have to use a bit
more complex formula:
=INDIRECT(ADDRESS(COLUMN(A1) - COLUMN($A$1) + ROW($A$1), ROW(A1) ROW($A$1) + COLUMN($A$1)))
Where A1 is the top-right-most cell of your source table. Also, please mind the use of absolute
and relative cell references.
2. Copy the formula through the range where you want to put the transposed data as usual by
dragging a small black cross in the lower right hand corner of a selected cell or range of cells.
That's it! In your newly created table, all of the columns are switched to rows.
However, the transposed cells do look very plain and dull, compared to the original data.
But don't get disappointed, this is not a problem at all. You can easily restore the source
formatting in this way:
Summing up, INDIRECT seems to be a more flexible way to turn rows to columns in Excel than
the TRANSPOSE function.
Advantages: you can easily edit any cell(s) in the transposed table, at the same time it stays
linked to the original table and gets updated automatically whenever you make changes in the
source data.
Shortcomings: in fact, I can see only one - the formatting of the ordinal data is not saved.
Though, you can quickly restore it, as shown above.
Now that you've got a feel how the INDIRECT function works, you may want to get the insight of
what the formula is actually doing and why we use it in combination with the ADDRESS
function. If you are not interested in tech details, you can skip directly to the next (the easiest!)
way ofextracting certain rows and converting them to columns.
INDIRECT and ADDRESS functions - syntax and logic
INDIRECT function, as its name suggests, is used to indirectly reference a cell. For example, if
you want to have the value of cell B1 in cell A8, then you enter this formula in A8
=INDIRECT("B1").
But the real power of the INDIRECT function is that it can turn any string into a reference,
including a string that you build up using other functions and the values of other cells. And this is
exactly what we are going to do next. If you are following up to this, you will understand all the
rest with ease : )
As you remember, we have used 3 more functions in the formula - ADDRESS, COLUMN and
ROW.
The ADDRESS function is used to obtain the address of a cell by the row and column numbers
you specify, respectively. Please remember this: first - row, second - column. For example,
ADDRESS(8,1) returns $A$8.
The COLUMN function returns the column number of the given cell reference. For example,
=COLUMN(A3) returns 1, because column A is the 1st column. As you can easily guess, the
ROW function works exactly in the same way for rows.
And now, let me remind you the entire formula that we've used to convert rows to columns in
our Excel worksheet: =INDIRECT(ADDRESS(COLUMN(A1),ROW(A1)))
As you see, in the ADDRESS function, we specify first COLUMN(A1) and then ROW(A1), and
this is what actually does the trick! Remember, the ADDRESS function interprets the first
number as a row number, and the second as a column number. In other words, the ADDRESS
function takes a column number returned by the COLUMN function and changes it to a row
number, then takes a row number and turns it to column, i.e. swaps rows to columns.
Now that you know what each function does, let's sum up the entire logic: COLUMN and ROW
functions return the column and row numbers, respectively -> ADDRESS function converts
column to row and row to column - > INDIRECT function outputs the rotated data to another cell
in your Excel spreadsheet. Nothing dreadful at all, is it?
The task sounds trickier than everything else we have done so far, right? But the solution is very
simple! You won't need any complex functions or formulas, just a few clicks in the Extract Data's
wizard.
Extract Data is an add-in for Microsoft Excel 2013 - 2003 specially designed for extracting rows
of data from Excel worksheets and converting rows to columns. I will give you a quick example
demonstrating how it works.
1. Select the table from which you want to extract the rows and click on the Extract Data icon on
the Excel Ribbon > Ablebits Data tab. You can actually click on any cell in your table and the
add-in will select the entire table automatically.
2. Select the rows you want to retrieve. You can choose to extract data from all the columns by
checking the Columns check box or from some of the columns, as show in the screenshot
below.
2. In this step, you specify the column by which you want to group the extracted data, it's
thePosition column in our case. Also, you choose whether to place the extracted and rotated
rows in one spreadsheet or separate sheets, in the same or a different worksheet.
If you are not sure which exactly layout suits you better, hover the mouse over the i icon to
the right of the option you choose and you will see a mockup of how the data will be transposed.
3. Finally, you choose the destination for extracted and converted rows - the same workbook or
a new workbook. You may also choose whether to add headers and auto fit column width.
How to split cells in Excel: Text to Columns, Flash Fill and formulas
In this article you will find several options to split cells and entire columns in Excel 2010 and
2013. Examples and screenshots illustrating the use of Text to Columns and Flash Fill features
as well as a handful of formulas to separate names, text and numerical values will help you
choose the best approach for splitting your data in Excel.
Generally, you may need to split cells in Excel in two cases. Firstly, when you import data from
some external database or a web-page and all of the entries get copied into one column while
you want them in separate columns. Another scenario is splitting data from an existing table for
better filtering, sorting or a detailed analysis.
What we want is to split this text into individual columns so that our table has the following
columns from left to right: First Name, Last Name, Country, Arrival Date and Status.
1. If your table has one or more columns next to the column you want to split, you start
bycreating new empty columns into which you want to divide cells. This step is needed in
order for your existing data won't get overwritten.
In our example, we have the Status column right after the Participants column and we want to
add new columns such as Last Name, Country and Arrival Date before the Status column.
If someone has forgotten, I'll remind you a quick way to insert multiple columns in Excel.
Select one column by clicking its header and drag to the right or left to select the number of
columns you want to insert. Then right click on the selected columns and choose Inset from the
context menu.
The result will be similar to what you see in the screenshot below (new columns added to the
left of the selected ones):
Note: If you don't have any adjacent columns next to the column you want to separate, this step
is not actually needed and you can skip it.
2. Select the column you want to split, navigate go to Data Tools tab and click the Text to
Columns button.
3. The Convert Text to Columns wizard opens and in the first step of the wizard, you choose the
type of data. Since our entries are delimited with spaces and commas, we
choose Delimited type (Fixed width type is explained a bit later). When done, click Next to
continue.
4. On the next step you specify the delimiters your data contain and the text qualifier.
Setting the delimiters. If your data is separated with one or more delimiters, you select all
appropriate options available under the Delimiters section or enter your own delimiter in
the Otherbox.
In our example, we set Space and Comma as the delimiters and check the "Treat consecutive
delimiters as one" option. This option would help to prevent excess parsing of data, e.g. if there
Specifying the text qualifier. You may need this option if the column you want to split contains
some values enclosed in quotation marks or apostrophes and you'd rather not split such
portions of text and treat them as a single value. For example, if you choose a comma as the
delimiter and a quotation mark (") as your text qualifier, then any words enclosed in "",
e.g. "California, USA", will be put into one cell as California, USA. If you select {none} as the text
qualifier, then "California will be imported into one column and USA" into another.
Near the bottom of the dialog window, you can see the Data preview section. Before you
clickNext, it stands to reason to quickly scroll down to make sure Excel has properly converted
all of your text data to columns.
5. Just two more things are left for you to do - choose the data format and select the destination
for split cells.
You can choose the data format for each of the columns into which the data is separated. By
default, the General format is set for all columns. We leave it as is for the first 3 columns and
switch to the Data format for the 4th column, which seems quite logical because it lists the arrival
dates :)
To change the data format for a particular column, click on the column in the Data
preview section to highlight it and then set the wanted format under the "Column data format"
section.
In the same step of the wizard, you can choose the destination column for the separated data.
To do this, click the range selection icon
(in Microsoft terms, it's called Collapse Dialog icon)
to the right of the Destination box and select the far left-hand column where you want the split
cells to appear. Regrettably, you are not able to import the separated columns to another
spreadsheet or workbook, you would get the invalid destination error if you try to do this.
Tip: If you do not want to import some column(s) you see in the data preview, select it and
check Do not import column (skip) radio button.
6. Click Finish and you are done!
Here's what you do to split such a column into two columns in Excel.
1. Start the Convert Text to Columns wizard as explained in the above example. In the first step
of the wizard, choose Fixed width and click Next.
2. Set the columns' widths using the data preview section. As you see in the screenshot below,
a vertical line represents a column break and to create a new break line, you simply click at the
needed position. Double-clicking a break line removes the break, and if you want to have a
break in some other position, click the line and drag it with the mouse. In fact, you can see the
same instructions in the upper part of the dialog window :)
Since our product IDs contain 9 characters each, I've set the break line exactly at this point, as
shown in the image above.
3. In the next step, choose the data format and destination for the split cells as explained in
theprevious example, and then click the Finish button to complete the process.
Splitting merged cells in Excel
If you've merged some cells in your Excel sheet and now you want to have them in separate
columns again, go to the Home tab > Alignment group, click a little black arrow next to
the Merge & Center button and choose Unmerge Cells from the drop-down list.
This will unmerge cells, but won't work a treat since all of your values will remain in the left-hand
column. Alas, you'd need to use the Text to Columns feature again to split data from one column
into two or more columns.
Separate data in one column to several columns with Excel 2013 Flash Fill
If you have already upgraded to Excel 2013, you can benefit from the new Flash Fill feature
and have Excel to automatically fill (in our case - split) your data when it detects a pattern.
If you are not familiar with this feature, I'll try to briefly explain the concept. This tool analyzes
the data you are entering in a worksheet and tries to figure out where you take the data from
and how exactly you want it to appear in a new column. Once Flash Fill recognizes what you're
doing and detects a pattern in your initial data, it will make suggestions and a series of entries
will appear across the new column, literally in a flash. Thus, you can use this tool to take some
part of the data residing in one or several columns and enter only that data in a new column. I
think you'll better understand what I'm talking about from the example that comes below.
First off, make sure the Flash Fill option in enabled. You can find it on the File tab > Options >
Advanced > Automatically Flash Fill.
Well, now let's see how you can have parts of cell values automatically copied to other cells.
Once you've turned the Flash Fill feature on, start typing the parts of the data you want to have
in other cells. As you type, Excel will try to detect a pattern in the new values you are entering
and as soon as it senses the pattern, it will populate similar data into other cells automatically.
To get a feel how it works, have a look at the screenshot below:
As you can see, I've typed just a couple of names in column B, and Excel's Flash Fill pulled the
other names from column A. If you are happy with what you see, simply press Enter and you will
have the entire column populated with text parts (or numeric values). This is a really smart
feature, isn't it?
If Flash Fill is turned on in your Excel but it doesn't make any suggestions when you are typing
data that matches a certain pattern, you can start it manually by clicking Data > Flash Fill, or
press Ctrl+E.
And you can easily split such "simple" names to 2 columns using the following formulas:
A
Full name
First name
Last name
FirstName LastName
=LEFT(A2,
SEARCH(" ",A2,1))
=RIGHT(A2,LEN(A2)SEARCH(" ",A2,1))
Resul
t:
Ronnie Anderson
Ronnie
Anderson
Feel free to copy these formulas and paste them across the entire columns in your Excel sheet,
just remember to replace A2 with the address of your first cell with data.
For those who are interested to know what the formulas actually mean, I'll try to explain in more
detail:
SEARCH or FIND function. These are absolutely identical functions that look for a text
value in a specified cell.
Formula Syntax: =SEARCH(find_text,within_text,start_num) means (what you are
looking for, where you want to search, character position to start).
In our example, SEARCH(" ",A2,1) says that we want to find a space " " in cell A2 and the
search starts from the 1st character.
Note: If your search starts from the first character, you may actually omit start_num in a formula
and simplify it to =LEFT(A2, SEARCH(" ",A2)).
LEFT and RIGHT functions - pull the left or right part of the text in the specified cell,
respectively.
Formula Syntax: =LEFT(text, num_chars) means (what text to take, number of characters
to extract).
In our example, =LEFT(A2, SEARCH(" ",A2,1)) pulls the left part of the text from cell A2 until the
first found space.
LEN function - counts the length of a string, i.e. the number of characters in the specified
cell.
Formula Syntax: =LEN(text).
In our example, LEN(A2) counts the number of characters in A2.
If the names in your table contain Middle names or suffixes, you will need a bit more complex
formulas that include the MID function.
Here are the formulas to use when the names to be split include either a middle name or one
middle initial.
Full name
First name
Middle
name
Last name
FirstName
MiddleName
LastName
=LEFT(A2,
FIND(" ",A2,1))
=MID(A2,
FIND("
",A2,1)+1,
FIND(" ",A2,
FIND("
",A2,1)+1)FIND("
",A2,1))
Resul
t:
Sally K. Brooke
Sally
K.
Brooke
MID function - extracts a substring (i.e. a specified number of characters) from a text
string.Formula Syntax: = MID(Text, Start_num, Num_chars) means (the piece of data
you want to take, starting character, the number of characters to extract).
You can use a similar MID formula to split names with suffixes:
A
Full name
First name
Last name
Suffix
FirstName LastName
Suffix
=LEFT(A2,
FIND(" ",A2,1))
=MID(A2,
FIND("
",A2,1)+1,
FIND(" ",A2,
FIND("
",A2,1)+1)( FIND("
",A2,1)+1))
Resul
t:
Robert
Furlan
Jr.
And here come the formulas to split last names that come first with comma, and the middle
names appear at the end:
A
Full name
First name
Middle name
Last Name
LastName,
FirstName
MiddleName
=MID(A2,SEARC
H(" ",A2,1)+1,
FIND(" ",A2,
FIND("
",A2,1)+1)FIND(" ",A2,1))
=RIGHT(A2,LEN(
A2)- FIND(" ",A2,
FIND("
",A2,1)+1))
=LEFT(A2, FIND("
",A2,1)-2)
Resul
David
Mark
White
t:
As you understand, these formulas work not only for separating names in Excel. You can use
them to split any other data from one column into several columns. For example, you use the
following formulas to split text data separated with commas.
A
State,
Abbr.,
Capital
State
Abbr.
Capital
FirstWord,
SecondWor
d,
ThirdWord
=LEFT(A2,
SEARCH(",",
A2)-1)
=MID(A2, SEARCH(",",A2) +
2,
SEARCH(",",A2,SEARCH(",",
A2)+2) - SEARCH(",",A2) 2)
=RIGHT(A2,LEN(
A2) SEARCH(",", A2,
SEARCH(",", A2)
+ 1))
Re
s.
Alabama,
AL,
Montgome
ry
Alabama
AL
Montgomery
And here you can see the real example in Excel 2010, the data from the first column is split into
three columns.
Of course, all of the above mentioned formulas will help you separate the names from one
column into several columns... provided that you have a homogeneous set of data. I mean the
formulas will work fine when all names are of the same pattern, e.g. the first name and the last
name; or the first name, middle name and last name etc. But in real tables, you may often have
names in different formats and in this case the formulas will only mess up your worksheet like
this:
If you want to separate such names into several columns, you'd better go with Excel's Text to
Columns feature. And yet even a better alternative is to use the Split Names add-in. This tool is
specially designed for splitting names in Excel 2013, 2010, 2007 and 2003 and it perfectly
recognizes multi-part names, over 80 salutations and about 30 different suffixes.
I've added a few salutations and suffixes to my original data, as you'll notice in the screenshot
below, and now let's see how the Split Names add-in will cope with it:
1. Select the cells with names you want to separate and click the Split Names icon on the Excel
Ribbon > Ablebits Data group. In fact, you can select the entire column for the sake of time and
the add-in will pick cells with data only.
2. Choose the parts into which you want to divide names in your Excel spreadsheet. The
following options are available to you: First name, Middle name, Last name, Salutation /
Title, and Name suffix / post-nominal letters.
3. Click Split and you are done! The new columns with separated names will be inserted to the
right of your original column.
No formulas, no fiddling with delimiters or line breaks, no pain at all. Just a couple of clicks is all
it takes.
Wrapping up, if splitting names in Excel is not a one-time task for you and you need to perform
this operation on a regular basis, you can go ahead and download a trial of the Split Names
add-in. This tool works with all versions of Microsoft Excel 2013, 2010, 2007 and 2003. And if
you find that the Split Names add-in is well suited for your needs, grab this coupon code AB14BlogSpothat we provide especially for our blog readers and get your license with 15% discount.
Alternatively, you can use this direct order link: get Split Names for Excel with 15% off.
Thank you for taking time for reading!
How to print row and column headers of Excel spreadsheets on every page
Today I'd like to tell you about a small but important feature tucked away in Excel 2013 and its
previous versions. In this article you'll learn how to make header rows and column headers print
on each page.
If you often have to print large and complex Excel worksheets, I am sure that you face this
problem as often as I do. I can easily scroll up and down through the document without losing
sight of the column titles because I have the header row frozen. However, when I print the
document, the top row is printed only on the first page. If you are sick and tired of turning the
printouts back and forth to see what kind of data is in each column or row, feel free to find out
the solution to the issue in this article.
4. Make sure that you're on the Sheet tab of the Page Setup dialog box.
5. Find Rows to repeat at top in the Print titles section.
The Page Setup dialog window is minimized and you get back to the worksheet.
You can notice that the cursor changes to the black arrow. It helps to choose an entire row with
one click.
7. Select a row or several rows that you want to print on every page.
Note: To select several rows, click on the first row, press and hold the mouse button and drag to
the last row you want to select.
8. Click Enter or the Collapse Dialog button again to return to the Page Setup dialog box.
Note: You can skip steps 6-8 and enter the range using the keyboard. However, pay attention to
the way you enter it you need to use the absolute reference (with the dollar sign $). For
example, if you want to see the first row on every printed page, the reference should look like
this: $1:$1.
9. Click on Print Preview to see the result.
There you go! Now you know exactly what the columns mean on every page.
Get a header column on every printout
When your worksheet is too wide, you'll have the header column on the left only on the first
printed page. If you want to make your document more readable, follow the steps below to print
the column with row titles on the left side of every page.
1. Open the worksheet that you want to print.
2. Go through steps 2-4 as described in Repeat Excel header rows on every page.
3. Click the Collapse Dialog button to the right of the Columns to repeat at left box.
4. Pick a column or columns that you want to see on every printed page.
5. Click Enter or the Collapse Dialog button again to check if the selected range is displayed in
the Columns to repeat at left field.
6. Press the Print Preview button in the Page Setup dialog box to look at your document
before printing.
Now you don't have to turn the pages back and forth to find what the values in each row mean.
Print row numbers and column letters
Excel normally refers to worksheet columns as letters (A, B, C) and to rows as numbers (1, 2,
3). These letters and numbers are called row and column headings. As opposed to row and
column titles that are printed only on the first page by default, the headings are not printed at all.
If you want to see these letters and numbers on your printouts, do the following:
1. Open the worksheet that you want to print with the row and column headings.
2. Go to the Sheet Options group on the PAGE LAYOUT tab.
3. Check the Print box under Headings.
Note: In case you still have the Page Setup window opened on the Sheet tab, just check
theRow and column headings box in the Print section. It also makes the row and column
headings visible on every printed page.
4. Open the Print Preview pane (FILE -> Print or Ctrl+F2) to check the changes.
How to merge rows in Excel 2010 and 2013 without losing data
This tutorial provides solutions for 4 different scenarios of merging rows in Excel. See how you
can quickly merge multiple rows without losing data; combine duplicate rows, repeatedly merge
blocks of rows and consolidate matching rows from two different spreadsheets.
Merging rows in Excel is one of the most common tasks that all of us need to perform every now
and then. The problem is that Microsoft Excel does not provide any decent tool to do this. For
example, if you try to combine two or more rows in your worksheet using the Merge &
Centerbutton (Home tab > Alignment group), all you'll get is the following error message:
"The selection contains multiple data values. Merging into one cell will keep the upper-left most
data only."
If you click OK, the merged cells will contain only the value of the top-left cell, all other data will
be gone. So, obviously we need to come up with some other solution. And further on this this
article you will find several methods that will let you merge multiple rows in Excel without losing
any data.
When it comes to merging Excel rows, there are two ways to achieve the desired result:
",A3)
Merge rows and separate the values with comma: =CONCATENATE(A1,", ",A2,",
Merge rows with spaces between the data: =CONCATENATE(A1," ",A2," ",A3)
Combine rows without spaces between the values: =CONCATENATE(A1,A2,A3)
I believe you have already deduced the general rule to write such a formula - simply enter all
cells to be merged separated with commas, and then type the separator in between, e.g. ", " is a
comma with a space; " " is only a space.
So, let's see how the CONCATENATE formula will work on the real data.
1. Select an empty cell on the sheet and enter the formula into it. We have 9 rows of data, so
the formula is going to be pretty large: =CONCATENATE(A1,", ",A2,", ",A3,", ",A4,", ",A5,",
",A6,", ",A7,", ",A8)
2. Copy the formula across all other cells in the row, the result should look similar to this:
3. Now you have several rows of data merged into one row. But your combined rows are, in fact,
formulas and if you want to convert them to values, you can simply copy / paste the merged
rows to some other row in your spreadsheet. The following tutorial explains how to do this in
detail:How to replace formulas with their values in Excel.
How to combine rows in Excel using the Merge Cells add-in
The Merge Cells add-in is purposed for combining various types of cells in Excel. It merges
individual cells as well as combines data from entire rows or columns. This is how the Merge
Cells button looks like on the Excel Ribbon:
To merge two or more rows in your table, proceed with the following 4 steps:
1. Select the rows you want to merge and click on the Merge Cells icon.
2. The Merge Cells dialog window will open with your table or range already selected, as you
can see in the screenshot below. In the upper part of the window, you specify three basic things:
How you want to join cells. To merge rows of data, select "column by column".
How to separate the merged values. There is an array of standard separators to choose
from: comma, space, semicolon and even line break! If you want to use some other separator,
merely type it directly in this field.
Where to place the merged cells. This can be either the top cell or bottom cell.
3. Now let's have a quick look at the lower part of the window to see if you need any aditional
options:
Clear the content of selected cells. Select it if you want the data to remain in the merged
cells only.
Merge all areas in the selection. This option will let you merge rows in two or more nonadjacent ranges.
Skip empty cells and Wrap text. These two are self-explanatory, aren't they?
And finally, you see the "Create a backup copy of the worksheet" option, checked by
default. This is just a precaution that will keep you on the safe side and ensure that you won't
lose your data in any case.
4. Now let us click the Merge button and see what we get as a result - perfectly merged rows of
data separated with line breaks!
You can download a fully-functional trial version of Merge Cells addin now, try it on your own
data and see if it's the right tool for you. The add-in works with all versions of Excel 2013, 2010,
2007and 2003.
How to combine duplicate rows into one (keeping unique values only)
The task: you have some Excel database with a few thousand entries. A bunch of values in one
of the columns are essentially the same while data in other columns are different. What you'd
like to have is combine data from duplicate rows based on a certain column, making it a comma
separated list. Additionally, you may want to merge unique values only, omitting duplicates and
skipping empty cells.
Finding and merging duplicate rows in Excel may be a real nightmare and obviously everyone
would like to avoid doing this work manually. In this case, another add-in, Combine Rows
Wizard, may come in truly handy.
As I've said, combining duplicate rows in Excel seems to be a pretty tricky task, but the
Combine Rows Wizard will walk you through the process making it really simple. And again,
you'll need just 4 quick steps:
1. Select the duplicate rows you want to merge and click the Combine Rows Wizard icon on
the ribbon. Make sure the "Create a backup copy" option is checked, especially if you are using
2. Select the key column. In our example, we're selecting the "Customer" column (A) because
we want to combine rows based on customer name. If you want to skip empty cells, be sure to
3. Choose the columns to merge. On this step you select the columns whose data that you
want to combine and specify the delimiter: semicolon, comma, space, line break or any other
character(s) of your choosing. Two additional options in the upper part of the window let you:
4. Click the Finish button and you'll see the result in a moment.
That was pretty easy, isn't it? To make sure of this, go ahead and download the trial version of
Combine Rows add-in. You can use it with any version of Excel 2013, 2010, 2007 and 2003.
If you have a fairly few entries to be combined, you can select each 3 rows and merge each
block individually using the Merge Cells Wizard as we discussed in How to merge Excel rows
without losing data. But if you have hundreds and thousands of records in your database, this is
definitely not a very elegant solution. There is a quicker way to achieve the needed result:
1. Create an additional column in your worksheet; it is column C in our example. Let's name
itBlock Id, or maybe you can come up with a more meaningful name : )
2. Write the following formula to the 2nd cell of that column (C2) because most likely your table
has headers: =INT((ROW(C2)-2)/3). And then copy it across the entire column.
Now, what does this formula actually do? It adds a unique number to each block of rows to be
merged, as shown in the screenshot:
In more detail, the INT function in Excel is used to round a number downwards to the next
lowest integer. (C2)-2 deducts the row number where your data start, for the formula to start
counting from zero. For example, our data start from the 2nd row, so we deduct 2. If your data
(actual data, not table headers) start, say, from row 5 and you enter the formula in cell D5, then
you put (D5)-5. And finally, we divide by the number of rows to be merged in each block (since
we are combining the blocks of three rows, we add /3 at the end of the formula). Phew, I do
hope my explanation makes sense. If not, don't hesitate to ask in comments and I'll try to come
up with something easier to comprehend : )
3. Well, the previous step actually did the main part of the work. Now you just need to merge the
rows based on column Block Id using the Combine Rows Wizard, exactly in the same way as
4. Delete the Block ID column since you don't need it any longer and you are done! Funny
enough, that we've needed 4 steps again, like in two previous examples : )
Merge matching rows from 2 Excel worksheets without copying / pasting
Task: you need to merge rows from 2 tables based on a common column. The tables may be
located in the same sheet, in two different spreadsheets or even in two different workbooks. For
example, you have sales reports for January and February in two different worksheets and you
Mind you, each workbook may have a different number of records and different order of
products name, so you cannot simply copy and paste the "Feb Sales" column to the first
workbook because the products won't match.
Another add-in from AbleBits will work a treat in this case - Merge Tables Wizard. This tool will
find, match and merge rows from two Excel worksheets in seconds, no matter how many rows
each spreadsheet contains. The design of the wizard is pretty much similar to the Combine
Rows Wizard we've used in two previous examples, so it should already look familiar to you : )
Okay, to combine matching rows from 2 spreadsheets, do as follows:
1. Select the 1st table, this is the main table that you want to update, and click the Merge
Tables button on the Ribbon (Ablebits Data > Merge).
This will open the Merge Tables Wizard's dialog with your first table already selected, so simply
click Next.
2. Select the second worksheet, i.e. a lookup table where you want to search for matching rows.
3. Choose the column with unique values that exists in both tables, it will be used as a unique
identifier. It our example, it can be either Product Name or Product ID, or both.
You can also click the Auto Detect button at the bottom left-hand corner and the wizard will find
the key column(s) automatically.
4. Choose which column(s) you want to update and which add to the end of the 1st table. Since
we want to add only the "Feb sales" column, let's select it and click Next.
5. On the next step, the Merge Tables Wizard provides a few additional options, such as:
Actually, there are some more options, as you can see in the screenshot below:
If you don't need any of these options for now, you can skip this step and click the Finish button.
However, if your second worksheet may contain some rows that do not exist in the first
spreadsheet and you do want to add them, select Add non-matching rows to the end of the
table.
Now click Finish, wait for a couple of seconds and as the result you have all matching rows from
two Excel worksheets merged into a single table:
If you are interested to try the Merge Tables Wizard, go ahead and download a trial
version here. As well as the two previous tools, it support Microsoft Excel 2013 - 2003.
How do I get these merging tools for Excel?
First off, you can download 15-day fully-functional trial versions to make sure the add-ins really
suite your needs, here is the download page.
If you like any of the merging tools described in this article, you have several options to get
them:
1. Buy any of the add-ins as a separate product using the order page.
2. Get 3 merging tools in a bundle and safe over 25% off their individual prices. In other
words, you pay only for 2 add-ins and get a 3rd one for free! The bundle includes Merge
Cells, Combine Rows Wizard and Merge Table Wizard, and here's the order form.
3. Have these 3 merging tools + 20 more add-ins as part of Ultimate Suite for Excel.
Note: This is a really important note, don't disregard it : ) Before you proceed to the order page,
be sure to copy the coupon code that we provide especially for our blog readers: AB14BlogSpo. It will give you an additional 15% discount on any Ablebits product.
Hopefully, now you can merge rows in your Excel sheets exactly as you want them. If you are
looking for something different and have not found the solution in this article, just leave a
comment and we will try to figure out a way together. Thank you for reading!
How to swap columns in Excel by drag-n-drop and other ways to move columns
In this article you will learn a few methods to swap columns in Excel tables. You will see how to
drag columns with a mouse and how to move a few non-contiguous columns at a time. The
latter is often considered unfeasible, but in fact there's a tool that allows moving several nonadjacent columns in Excel 2013, 2010 and lower.
If you extensively use Excel tables in your daily work, you know that whatever logical and well
thought-out a table's structure is, you have to reorder the columns every now and then. For
example, you might need to swap a couple of columns to view their data side-by-side. Of
course, you can try to hide the neighboring columns for a while, however this is not always the
best approach because you may need to see data in those columns as well.
Surprisingly, Microsoft Excel does not provide any straightforward way to perform this common
operation. If you try to simply drag a column name, which appears to be the most obvious way
to move columns, you might be confused to find that it does not work, even in Excel 2013.
All in all, there are four possible ways to switch columns in Excel, namely:
3. Press and hold down the Shift key, and then drag the column to a new location. You will see
a faint "I" bar along the entire length of the column and a box indicating where the new column
will be moved.
4. That's it! Release the mouse button, then leave the SHIFT key and find the column moved to
a new position.
You can use the same technique to drag several columns in your Excel table. To select
several columns, click the heading of the first column you need to move, press and hold Shift,
and then click the heading of the last column. Then follow steps 2 4 described above to move
the columns, as shown in the screenshot.
Note: It is not possible to drag non-adjacent columns and rows in Excel sheets, even in Excel
2013.
The drag and drop method works in Microsoft Excel 2013, 2010 and 2007 and can be used for
moving the table's rows as well. It might require some practice, but once mastered it could be a
real time saver. Though, I guess the Microsoft Excel team will hardly ever win an award for the
most user friendly interface on this feature : )
Swap Excel columns by cut /paste
If manipulating the mouse pointer is not your technique of choice, then you can change the
columns order by copying and pasting them. Please keep in mind that there're a few
specificities here depending on whether you want to move a single column or several columns
at a time:
If you are more comfortable with Excel shortcuts and keyboard, then you may like the following
way better:
Select any cell in the column and press CTRL+SPACE to select the whole column.
Drag several columns using the mouse (in my opinion, this is the fastest way)
Cut and paste each column individually (probably not the best approach if you have to
move a lot of columns)
Copy, paste and delete (allows moving several adjacent columns at a time)
Swap multiple columns by copying, pasting and deleting
If dragging columns with a mouse does not work for you for some reason, then you can try to rearrange several columns in an Excel table is this way:
1. Select the columns you want to switch (click the first column's heading, press Shift and then
click the last column heading).
An alternative way is to select only the headings of the columns to be moved and then press
Ctr+Space. This way will select only cells with data rather than entire columns, as shown in the
screenshot below.
Note:. If you are re-arranging columns in a range, either way will do. If you need to swap a few
columns in a fully-functional Excel table, then select the columns using the second way (cells
with data only), otherwise you may get the error "The operation is not allowed. The operation is
attempting to shift cells in a table of your worksheet".
2. Copy selected columns by pressing Ctrl+C or right click the columns and choose Copy.
3. Select the column before which you want to insert the copied columns and either right click it
and choose Insert copies cells, or simultaneously press Ctrl and the plus sign (+) on the
numeric keypad.
Among other utilities, the Quick Tools include Column Manager that lets you change the order
of columns on the fly, without manual copying / pasting or learning a handful of shortcuts. This is
how the Column Manager would look like on your Excel ribbon:
Clicking the Column Manager's icon opens a special pane that displays a list of columns in your
worksheet, like this:
And now you can easily move a single column or swap several columns in your table either
bydragging the columns' names on the pane or by using the up and down arrow buttons on
the toolbar. You select multiple columns in the usual way by pressing the Shift or Ctrl key, for
adjacent and non-adjacent columns respectively. As you can see in the screenshot, even noncontiguouscolumns can be moved in one fell swoop!
When working with the Column Manager, a really nice thing is that all your manipulations are
simultaneously performed on your worksheet. For example, when you select a few columns on
the pane, they automatically get selected in the sheet, which lets you visually see all the
changes and have full control over the process.
Another, a truly wonderful feature, is the ability to move a column or several columns to the end
or to the beginning of the table in a button click.
And finally, as a nice bonus, comes the ability to auto fit the width of selected columns.
I have to admit, that I really love this little smart add-in. Together with the other 9 quick tools
included in the package, it makes common operations in Excel not only faster and easier, but
actually enjoyable. Of course, you should not take my words for granted because I've got used
to them and therefore am sort of biased : )
So, go ahead and download a 15-day trial of Quick tools to see for yourself. The add-ins work
with all versions of Excel 2013, 2010, 2007 and 2003. If you like the tools, please do come back
and request a special 15% off coupon code that we provide especially for our blog readers.
And thank you for reading!
How to view, change and remove document properties in Excel 2010 and 2013
The time has come to tell you about different types of document properties, the ways of viewing
and changing them in Excel 2010 and 2013. In this article you'll also learn how to protect your
document from any modifications and remove personal information from your Excel worksheet.
Do you remember your feelings when you just started to use Excel 2010 or 2013? Personally I
sometimes felt angry when I couldn't find the necessary tool or option at the place where they
were in the previous Excel versions. This is what happened to the document properties in Excel
2010 / 2013. In these last two versions they are hidden deeper, but it won't take you much time
to dig them out.
In this article you will find a detailed guide how to view and change the document properties,
protect your document from any modifications and remove personal information from your Excel
worksheet. Let's get it started! :)
o
o
o
o
have to enter the values for any properties that are required, or correct any properties that are
wrong.
View document properties
If you don't know where to find the information about your document in Excel 2010 / 2013, here
are three ways to do it.
Method 1. Show the Document Panel
This method allows you to see the information about your document right in the worksheet.
1. Click on the File tab. You switch to the backstage view.
2. Choose Info from the File menu. The Properties pane is shown on the right-hand side.
Here you can already see some information about your document.
It'll automatically take you back to your worksheet and you'll see the Document Panel placed
between the Ribbon and the working area as on the screenshot below.
As you see, the Document Panel shows a limited number of properties. If you're eager to know
more about the document, move to the second method.
Method 2. Open the Properties dialog box
If you can't find the necessary information in the Document Panel, take the Advanced
Properties into use.
The first way to display the Advanced Properties is right from the Document Panel.
1. Click on 'Document Properties' in the top-left corner of the Document Panel.
Here you can see general information about your document, some statistics and document
contents. You can also change the document summary or define additional custom properties.
Do you want to know how to do it? Be patient! I'll share it with you a bit later in this article.
There is one more way to open the Properties dialog box.
1. Go through the first three steps that are described in Method 1.
The same Properties dialog box will appear on the screen as on the screenshot above.
Method 3. Use Windows Explorer
One more easy way of displaying the metadata is to use Windows Explorer without opening the
worksheet itself.
1. Open the folder with Excel files in Windows Explorer.
2. Select the file you need.
4. Move to the Details tab to view the title, subject, author of the document and other
comments.
Now you know different ways of viewing the document properties on your PC and I am sure
you'll find the necessary information without any problems.
Modify document properties
Earlier I promised to tell you how to change the document properties. So when you view
properties using Method 1 and Method 2 described above, you can immediately add the
necessary information or correct invalid data. As for Method 3, it's also possible if you don't have
Windows 8 installed on your computer.
The quickest way to add an author
If you need just to add an author, there is a very quick way to do it right up in Excel 2010 / 2013
backstage view.
1. Go to File -> Info
2. Move to the Related People section on the right side of the window.
3. Hover the pointer over the words 'Add an author' and click on them.
5. Click anywhere in the Excel window and the name will be automatically saved.
You can add as many authors as there are working on the document. This quick method can be
also used for changing the title or adding a tag or a category to the document.
Change the default author name
By default, the document author name in Excel is your Windows username, but this might not
properly represent you. In this case you should change the default author name so that Excel
will use your proper name later on.
1. Click on the File tab in Excel.
3. Select General on the left pane of the Excel Options dialog window.
4. Move down to the Personalize your copy of Microsoft Office section.
5. Type in the proper name in the field next to User name.
6. Click 'OK'.
4. Click on the Custom tab in the Properties dialog box that appears on your screen.
5. Choose a name for the custom property from the suggested list or type in a unique one in
theName field.
6. Select the data type for the property from the Type drop-down list.
7. Type in a value for the property in the Value field.
Note: The value format must meet your choice in the Type list. It means if the chosen data type
is Number, you have to type in a number in the Value field. Values that don't match the property
type are saved as text.
9. After you add a custom property you can see it in the Properties field. Then click 'OK'.
If you click on the custom property in the Properties field and then press Delete -> OK, your
just-added custom property will disappear.
Change other document properties
If you need to change other metadata, except the author's name, title, tags and categories, you
have to do it either in the Document Panel or in the Properties dialog box.
In case the Document Panel is open in your worksheet,you just need to set the cursor
in the field you want to edit and enter the necessary information.
If you've already opened the Properties dialog box, switch to the Summary tab and add
or update the information in the fields, click OK.
When you get back to the spreadsheet, any changes you made will be automatically saved.
Remove document properties
If you need to cover up your traces left in the document so that nobody will see your name or
your organization name in the document properties later, you can hide any property or personal
information from the public using one of the following methods.
5. The Document Inspector window will pop up and you can tick the issues you want to look
at. I'd leave them all selected though we're most interested in checking 'Document Properties
and Personal Information'.
6. When you make your choice, click Ispect at the bottom of the window.
7. Click on Remove All in each category you're interested in. In my case it's Document
Properties and Personal Information.
5. Click on 'Remove Properties and Personal Information' at the bottom of the dialog window.
Note: You can remove any document property from the file or several files using this method,
even if you have Windows 8 installed on your computer.
Protect document properties
Protection of document properties and personal information is used in case you don't want other
people to change any metadata or anything in your document.
1. Go to File -> Info.
2. Click on Protect Workbook in the Permissions section.
3. In Excel 2013 this section is named Protect Workbook.
5. Then you'll be informed that this document version will be final so that other people won't be
allowed to make any changes to it. You need to agree or press Cancel.
If you want to let some people modify the worksheet after all, you can set a password for those
who want to change something in the document.
1. Stay in the backstage view. If you are out of the backstage view and back to the worksheet,
click on the File tab again.
6. Click OK.
9. Choose the folder where you'd like to save the document and press Save.
Now your document is secured from unwanted editing. But be careful! People who know the
password can easily remove it from the Password to modify box thus letting other readers
change the information in the worksheet.
Wow! This post has turned out to be long! I tried to cover all the bases that concern viewing,
changing and removing the document properties so I hope you'll find proper answers to the sore
points involving metadata.
To be able to quickly insert values to other workbooks or sheets without wasting time on
copy/paste special.
To keep your original formulas unknown when you send a workbook to another person
(for example, your retail markup to the wholesale price).
To prevent the result from modifying when the numbers in the linking cells change.
Save the result of the rand() formula
If you have a lot of complex formulas in your workbook which make recalculating really
slow. And you cannot switch the "Workbook calculation" option to the manual mode.
Converting formulas to values using Excel shortcuts
Replacing formulas with values in 2 clicks
Converting formulas to values using Excel shortcuts
Suppose, you have the formula to extract domain names from URLs.
You need to replace its results with values.
Select all the cells with formulas that you want to convert.
Press Ctrl + C or Ctrl + Ins to copy formulas and their results to clipboard.
3. Press Shift+F10 and then V to paste only values back to Excel cells.
Shift + F10 + V is the shortest way to use Excel "Paste special - values only" dialog.
That's it! If this way is still not fast enough for you, have a look at the next tip.
3.
Ready :)
PS Feel free to explore other Quick Tools features. I can assure you that it will save 4-5 minutes
on one Excel task, 5-10 minutes on another task, and by the end of your day it will save you an
hour or more of your precious time. How much does an hour of your work cost?
How to count and sum cells by color in Excel 2010 and 2013
I this article you will learn how to count cells by color in Excel and get the sum of colored cells.
These solutions work both for cells colored manually and with conditional formatting. You will
also learn how to filter cells by several colors in Excel 2010 and 2013.
If you actively use diverse fill and font colors in your Excel worksheets to differentiate between
various types of cells or values, you may want to know how many cells are highlighted in a
certain color. If your cells' values are numbers, you may also want to automatically calculate the
sum of cells shaded with the same color, e.g. the sum of all red cells.
As all of us know, Microsoft Excel provides a variety of formulas for different purposes, and it
would be logical to assume that there are some to count cells by color. But regrettably, there is
no formula that would let us sum by color or count by color in a usual Excel worksheet.
Apart from using third-party add-ins, there is only one possible solution - utilize User Defined
Functions. If you know very little about this technology or have never heard this term before,
don't be afraid, you will not have to write the code yourself. You will find the perfect code (written
by our Excel guru) here and all that you will have to do is copy / paste it into your workbook.
Count by color and sum by color (if cells are colored manually)
Sum by color and count by color across the entire workbook
Count and sum colored cells (if conditional formatting is used)
Fastest way to count and sum cells by color in Excel
How to count by color and sum by color in an Excel worksheet
Suppose you have a table listing your company's orders where the cells in the Delivery column
are colored based on their value - "Due in X Days" cells are orange, "Delivered" items are green
and "Past Due" orders are red.
What we want now is automatically count cells by color, i.e. calculate the number of red, green
and orange cells in the worksheet. As I explained above, there is no straightforward solution to
this task. But luckily we have very skilled and knowledgeable Excel gurus in our team and one
of them has written the faultless code for Excel 2010 and 2013. So, move on with the 5 quick
steps below and you will know the number and sum of your color cells in a few minutes.
1. Open your Excel workbook and press Alt+F11 to open Visual Basic Editor (VBE).
2. Right-click on your workbook name under "Project-VBAProject" in the right hand part of the
screen, and then choose Insert > Module from the context menu.
Application.Volatile
sumRes = 0
indRefColor = cellRefColor.Cells(1, 1).Font.Color
For Each cellCurrent In rData
If indRefColor = cellCurrent.Font.Color Then
sumRes = WorksheetFunction.Sum(cellCurrent, sumRes)
End If
Next cellCurrent
SumCellsByFontColor = sumRes
End Function
4. Save your workbook as "Excel Macro-Enabled Workbook (.xlsm)".
If you are not very comfortable with VBA, you can find the detailed step-by-step instructions and
a handful of useful tips in this tutorial: How to insert and run VBA code in Excel.
5. Now that all "behind the scenes" work is done for you by the just added user-defined function,
choose the cell where you want to output the results and enter the CountCellsByColor function
into it:
CountCellsByColor(range, color code)
In this example, we use the formula =CountCellsByColor(F2:F14,A17) where F2:F14is
the range containing color-coded cells you want to count and A17 is the cell with a certain
background color, a red one in our case.
In a similar way, you write the formula for the other colors you want to count, yellow and green
in our table.
If you have numerical data in colored cells (e.g. the Qty. column in our table), you can add up
the values based on a certain color by using an analogous SumCellsByColor function:
SumCellsByColor(range, color code)
Note: If after applying the above mentioned VBA code you would need to color a few more cells
manually, the sum and count of the colored cells won't get recalculated automatically to reflect
the changes. Please don't be angry with us, this is not a bug of the code : )
In fact, it is the normal behavior of all Excel macros, VBA scripts and User-Defined Functions.
The point is that all such functions are called with a change of a worksheet's data only and
Excel does not perceive changing the font color or cell color as a data change. So, after coloring
cells manually, simply place the cursor to any cell and press F2 and Enter, the sum and count
will get updated. The same applies to the other macros you will find further in this article.
Sum by color and count by color across the entire workbook
The VB script below was written in response to Connor's comment (also by our Excel's
guru Alex) and does exactly what Connor requested, namely counts and sums the cells of a
certain color in all worksheets of the workbook. So, here comes the code:
?
Function WbkCountCellsByColor(cellRefColor As Range)
Dim vWbkRes
Dim wshCurrent As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
vWbkRes = 0
For Each wshCurrent In Worksheets
wshCurrent.Activate
vWbkRes = vWbkRes + CountCellsByColor(wshCurrent.UsedRange,
cellRefColor)
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
WbkCountCellsByColor = vWbkRes
End Function
Function WbkSumCellsByColor(cellRefColor As Range)
Dim vWbkRes
Dim wshCurrent As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
vWbkRes = 0
For Each wshCurrent In Worksheets
wshCurrent.Activate
vWbkRes = vWbkRes + SumCellsByColor(wshCurrent.UsedRange,
cellRefColor)
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
WbkSumCellsByColor = vWbkRes
End Function
You use this macro in the same manner as the previous code and output the count and sum of
the colored cells with the help of the following
formulas, =WbkCountCellsByColor() and =WbkSumCellsByColor(), respectively. Simply
enter either formula in any empty cell on any sheet without defining a range, specify the address
of any cell of the needed color in brackets, e.g. =WbkSumCellsByColor(A1), and the formula will
display the sum of all the cells shaded with the same color in your workbook.
Custom functions to get a cell's background color, font color and color code
Here you will find a summary of all the functions we've used in this example as well as a couple
of new ones that retrieve color codes.
Note: Please remember that all of these formulas will work only if you have added the userdefined function to your Excel workbook as demonstrated earlier in the article.
Functions to count by color:
CountCellsByColor(range, color code)- counts cells with the specified
background color.
In the above example, we used the following formula to count cells by
color=CountCellsByColor(F2:F14,A17) where F2:F14 is the selected range and A17 is the cell
with the needed background color. You can use all other formulas listed below in a similar way.
Well, counting cells based on color and getting the sum of colored cells was pretty easy, wasn't
it? Of course if you have that little VBA gem that makes the magic happen : ) But what if you do
not color cells manually and rather use conditional formatting, as we discussed in these two
articlesHow to change the background color of cells and How to change a row's color based on
cell value?
How to count by color and sum cells colored using conditional formatting
If you have applied conditional formatting to color cells based on their values and now you want
to count cells by color or sum the values in colored cells, I have bad news - there is no universal
user-defined function that would sum by color or count color cells and output the resulting
numbers directly in the specified cells. At least, I am not aware of any such function, alas : (
Of course, you can find tons of VBA code on the Internet that attempts to do this, but all those
codes (at least the examples I've come across, do not process conditional formatting such as
"Format all cells based on their values", "Format only top or bottom ranked values", "Format
only values that are above or below average", "Format only unique or duplicate values". Besides
that nearly all those VBA codes have a number of specificities and limitations because of which
they may not work correctly with certain workbooks or data types. All in all, you can try your luck
and google for an ideal solution and if you happen to find one, please do come back and post
your finding here!
The VBA code below overcomes the above mentioned limitations and works in Microsoft Excel
2010 and Excel 2013 spreadsheets with all types of condition formatting (kudos
to Alex again!). As a result, it displays the number of colored cells and the sum of values in
those cells, no matter which type of conditional formats are used in a sheet.
?
Sub SumCountByConditionalFormat()
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Long
Dim sumRes
Dim cntCells As Long
Dim indCurCell As Long
cntRes = 0
sumRes = 0
cntCells = Selection.CountLarge
indRefColor = ActiveCell.DisplayFormat.Interior.Color
For indCurCell = 1 To (cntCells - 1)
If indRefColor =
Selection(indCurCell).DisplayFormat.Interior.Color Then
cntRes = cntRes + 1
sumRes = WorksheetFunction.Sum(Selection(indCurCell),
sumRes)
End If
Next
MsgBox "Count=" & cntRes & vbCrLf & "Sum= " & sumRes & vbCrLf &
vbCrLf & _
"Color=" & Left("000000", 6 - Len(Hex(indRefColor))) & _
Hex(indRefColor) & vbCrLf, , "Count & Sum by Conditional
Format color"
End Sub
How to use the code to count colored cells and sum their values
1. Add the above code to your worksheet as explained in the first example.
2. Select a range or ranges where you want to count colored cells or/and sum by color if you
have numerical data.
3. Press and hold Ctrl, select one cell with the needed color, and then release the Ctrl key.
4. Press Alt+F8 to open the list of macros in your workbook.
5. Select the SumCountByConditionalFormat macro and click Run.
For this example, we selected the Qty. column and got the following numbers:
Count is the number of the cells with a particular color, a reddish color in our case that
marks "Past Due" cells.
Sum is the sum of values of all red cells in the Qty. column, i.e. the total number of "Past
Due" items.
Color is the Hexadecimal color code of a selected cell, D2 in our case.
Sample workbook for download
If you have any difficulties with adding the scripts to your Excel workbooks, such as compilation
errors, formulas not working and so on, please download this sample workbook with
theCountCellsByColor and SumCellsByColor functions ready for use and try them on your data.
Fastest way to count and sum cells by color in Excel - new!
Updated on 1-Jul-2014.
When we published this article, we hoped it would be popular because we used to get a lot of
questions about how to count and sum cells by color in Excel. But even in our wildest
expectations, we did not think it was going to be that popular! What you see in comments on
this page is just a tiny portion of the enormous feedback we have received. So, our team
decided to take a step further and create an Excel add-in that would count and sum cells by the
color you specify or by all colors in the selected range.
Let me introduce you our brand new add-in - Count & Sum by Color for Excel 2013, Excel 2010,
2007 and 2003. Once installed, it will place 2 buttons onto the Ablebits Data tab on your Excel
ribbon - One Color and All Colors, as you can see in the screenshot below:
The range where you want to count and sum the cells
Any color-coded cell
Color option - either background or font color
Once done, click Calculate and see the result in the lower part of the pane straight away! Apart
from the count and sum, the add-in calculates the average and finds the max and min values.
No macros, no formulas, no pain :)
If you want to copy the results to your worksheet, click the Paste results... button at the bottom
of the Count & Sum by Color pane.
And here is a list of the main features you will find in the Count & Sum by Color add-in:
Count and sum cells by color in all versions of Excel 2013, 2010, 2007 and 2003.
Handle cells color-coded manually and with conditional formatting.
Besides counting and calculating the sum, the following functions are available: Average,
Maximum and Mininum values.
An option to recalculate colored cells automatically when a new range is selected.
Copy and paste the results to any location on the current spreadsheet or to any other
sheet.
You can download a trial version of the Count & Sum by Color add-in here. Hopefully you will
like it, but we are keen to know your feedback, anyway : )
How can I get the Count & Sum by Color add-in?
Currently the add-in is available as part of the Ultimate Suite for Excel. This is a collection of our
best tools especially designed to deal with the most tedious, painstaking and error-prone tasks
in Excel.
In addition to the Count & Sum by Color add-in, the Ultimate Suite includes about 40 other
tools that can help you to:
Remove duplicates
Combine duplicate rows into one
Merge cells, rows and columns
Find and replace in all workbooks
Clean data in worksheets
And much more!
If you like the tools, be sure to benefit from a special 15% off coupon code that we provide
especially for our blog readers: AB14-BlogSpo
Hopefully, in this article you have found the information you were looking for. If not, you are
welcome to post a comment and we will try to help!
How to insert and run VBA code in Excel 2010, 2013 - tutorial for beginners
This is a short step-by-step tutorial for beginners showing how to add VBA code (Visual Basic
for Applications code) to your Excel workbook and run this macro to solve your spreadsheet
tasks.
Most people like me and you are not real Microsoft Office gurus. So, we may not know all
specificities of calling this or that option, and we cannot tell the difference between VBA
execution speed in Excel 2010 and 2013. We use Excel as a tool for processing our applied
data.
Suppose you need to change your data in some way. You googled a lot and found a VBA macro
that solves your task. However, your knowledge of VBA leaves much to be desired. Feel free to
study this step-by-step guide to be able to use the code you found:
2. Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of
the editor window) and select Insert -> Module from the context menu.
3. Copy the VBA code (from a web-page etc.) and paste it to the right pane of the VBA editor
("Module1" window).
To the very beginning of the code, after all code lines that start with Dim (if there are no
"Dim" lines, then add them right after the Sub line):
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
To the very of the code, before End Sub:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
These lines, as their names suggest, turn off screen refresh and recalculating the workbook's
formulas before running the macro.
After the code is executed, everything is turned back on. As a result, the performance is
increased from 10% to 500% (aha, the macro works 5 times faster if it continuously manipulates
the cells' contents).
4. Save your workbook as "Excel macro-enabled workbook". Press Crl+S, then click the "No"
button in the "The following features cannot be saved in macro-free workbook" warning dialog.
The "Save as" dialog will open. Choose "Excel macro-enabled workbook" from the "Save as
type" drop-down list and click the Save button.
5. Press Alt+Q to close the Editor window and switch back to your workbook.
How to run VBA macros in Excel
When you want to run the VBA code that you added as described in the section above:
press Alt+F8 to open the "Macro" dialog.
Then select the wanted macro from the "Macro Name" list and click the "Run" button.
How to remove carriage returns (line breaks) from cells in Excel 2010, 2013, 2007
In this tip you'll find 3 ways to remove carriage returns from Excel cells. You'll also learn how to
replace line breaks with other symbols. All solutions work for Excel 2013, 2010 - 2003
There can be different reasons for line breaks occurring in your text. Usually, carriage returns
appear when you copy text from a webpage, get a workbook that already contains line breaks
from a customer, or you add them yourself using Alt+Enter.
In any case, what you want to do now is delete carriage returns since they don't let you find a
phrase and make column contents look disorganized when you turn on the wrap text option.
All these 3 ways are really quick. Feel free to pick the one that suites you best:
Remove all carriage returns manually to quickly delete line breaks in 1 worksheet.
Delete line breaks using formulas to employ several formulas for a complex cell text
processing.
Use a VBA macro to get rid of line breaks in a number of workbooks.
Note:Initially the terms "Carriage return" and "Line feed" were used in a typewriter and meant
2 different actions, you can find more at Wiki.
Computers and text processing software were created taking into consideration the typewriter
specificities. That's why two different non-printable symbols are used now to indicate line break:
"Carriage return" (CR, ASCII code 13) and "Line Feed" (LF, ASCII code 10). Windows uses 2
symbols one by one: CR+LF, and LF for *NIX systems.
Be careful: in Excel you can find both variants. If you import data from a .txt or .csv file, you
are more likely to find Carriage Return + Line Feed. When you break a line using Alt+Enter ,
Excel inserts Line Feed only. In case you get .csv files from a person who uses Linux, Unix, etc.,
you'll find only Line Feeds again.
Remove Carriage Returns manually
Pros: the fastest way.
Cons: no any additional features :(.
Please find the steps for eliminating line breaks using Find and Replace:
1. Select all cells where you want to remove or replace carriage returns.
Handle both Windows and UNIX carriage return/ line feeds combinations.
=SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),""),CHAR(10),"")
The next formula will help you replace line break with any other symbol (comma+space).
In this case lines will not join and extra spaces will not appear.
=TRIM(SUBSTITUTE(SUBSTITUTE(B2,CHAR(13),""),CHAR(10),", ")
If you want to remove all nonprintable characters from text, including line breaks:
=CLEAN(B2)
Select all cells in column C and press Ctrl + C to copy the data to clipboard.
Now pick the cell B2 and press the Shift + F10 shortcut. Then just press V.
Remove the helper column.
VBA macro to get rid of line breaks
Pros: Being created once, can be reused in any workbook.
Cons: you need to have the basic knowledge of VBA.
The VBA macro from the example below deletes carriage returns from all cells in the currently
opened worksheet (active worksheet).
?
Sub RemoveCarriageReturns()
Dim MyRange As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each MyRange In ActiveSheet.UsedRange
If 0 < InStr(MyRange, Chr(10)) Then
MyRange = Replace(MyRange, Chr(10), "")
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
If you don't know VBA really well, see How to insert and run VBA code in Excel
o
o
o
2. In the first cell of the helper column (C2), enter the formula to trim excess spaces =TRIM(A2)
3. Copy the formula across the other cells in the column. Feel free to use some tips from Enter
the same formula into all selected cells at a time.
4. Replace the original column with the one that has the cleaned data. Select all cells in the
helper column and press Ctrl + C to copy data to clipboard.
Now pick the first cell in the original column and press Shift + F10 or the menu button
just press V.
. Then
Note: If after using the formula you still see extra spaces (the last cell on the screenshot),
please have a look at If the TRIM Function Doesn't Work
5. Repeat step 4 until you see the message "We couldn't find anything to replace." :)
3 clicks to neat data with Cell Cleaner add-in
If you often import data to Excel from external sources and spend much time polishing up your
tables, check out Cell Cleaner add-in for Excel.
This helpful tool will clean data imported from web or any other external source. It removes
leading and trailing spaces, excess blanks between words, non-breaking spaces, line breaks,
non-printing symbols and other unwanted characters. This add-in also converts words to
UPPER, lower or Proper Case. And if you need to change text numbers back to number format
and delete apostrophes, this will not be a problem.
0. Download and install Cell Cleaner add-in for Excel.
1. Select the range in your table where you want to remove excess spaces. For new tables I
usually press Ctrl + A to process all columns in a go.
3. The Cell Cleaner pane will open on the left side of your worksheet. Just select the needed
checkboxes, click the Trim button and enjoy your perfectly cleaned table.
Isn't it faster than with the two previous tips? If you always deal with data processing, this tool
will save you hours of precious time.
Remove all spaces between numbers
Suppose, you have a workbook with numbers where the digits (thousands, millions, billions) are
separated with spaces. Thus Excel sees numbers as text and no math operation can be
performed.
The easiest way to get rid of excess spaces is using the standard Excel Find & Replace option:
If you are concerned with promoting your web-site (like I am) or doing SEO at the professional
level promoting clients' web-sites for money, you often have to process and analyze huge lists of
URLs: Google Analytics reports on traffic acquisition, Webmaster tools reports on new links,
reports on backlinks to your competitors' web-sites (which do contain a great lot of interesting
facts ;) ) and so on, and so forth.
To process such lists, from ten to a million links, Microsoft Excel makes an ideal tool. It is
powerful, agile, extendable, and lets you send a report to your client directly from an Excel
sheet.
"Why is it this range, from 10 to 1,000,000?" you may ask me. Because you definitely don't need
a tool to process fewer than 10 links; and you will hardly need any if you have over a million
inbound links. I'd wager that in this case you'd already had some custom software developed
especially for you, with a business logic specifically tailored for your needs. And it would be me
who would peruse your articles and not the other way round :)
When analyzing a list of URLs, you often need to perform the following tasks: get domain
names for further processing, group URLs by domain, remove links from already processed
domains, compare and merge two tables by domain names etc.
o
o
o
o
Tip: I'd recommend using ahrefs.com to timely spot new links to your own site and your
competitors' web-sites.
1. Add the "Domain" column to the end of your table.
We have exported the data from a CSV file, which is why in terms of Excel our data are in a
simple range. Press Ctrl + T to convert them to an Excel table because it is far more convenient
to work with.
2. In the first cell of the "Domain" column (B2), enter the formula to extract a domain name:
The second formula may seem too long and complex, but only if you didn't see truly long
formulas. It's not without reason that Microsoft has increased the maximum length of formulas
up to 8192 characters in new versions of Excel :)
The good thing is that we don't have to use either an additional column or VBA macro. In fact,
using VBA macros to automate your Excel tasks is not so difficult as it may seem, see a very
good article - Tutorial with Excel examples about Macros. But in this particular case, we do not
actually need them, it's quicker and easier to go with a formula.
Note: Technically, www is the 3rd level domain, though with all normal web-sites www. is just an
alias of the primary domain. In the early days of the Internet, you could say "double u, double u,
double u our cool name dot com" on the phone or in a radio advert, and everyone perfectly
understood and remembered where to look for you, of course unless your coolname
was http://www.llanfairpwllgwyngyllgogerychwyrndrobwyll-llantysiliogogogoch.com/ :)
You need to leave all other domain names of the 3rd level, otherwise you would mess up links
from different sites, e.g. with "co.uk" domain or from different accounts on blogspot.com etc.
3. Since we have a full-fledged table, Excel automatically copies the formula across all cells in
the column.
In the next section you will learn how you can process a list of URLs based on the Domain
column.
Tip: If you may need to edit the domain names manually at a later time or copy the results to
another Excel worksheet, replace the formula results with values. To do this, proceed with the
following steps:
Click on any cell in the Domain column and press Ctrl+Space to select all the cells in
that column.
Press Ctrl + C to copy the data to Clipboard, then go to the Home tab, click the "Paste"
button and select "Value" from the drop-down menu.
6. Click OK.
Excel has created an outline of your data on the left hand side of the screen. There are 3 levels
of the outline and what you see now is the expanded view, or level 3 view. Click number 2 in the
upper left hand corner to display the final data by domains, and then you can click the plus and
minus signs (+ / -) in order to expand / collapse the details for each domain.
Highlight the second and all subsequent URLs in the same domain
In our previous section we showed how to group URLs by domain. Instead of grouping, you can
quickly color duplicate entries of the same domain name in your URLs.
For more details please see how to automatically highlight duplicates in Excel.
For example, my task is to color in red all domains that are in my spammer blacklist:
Not to waste much time, you can compare your tables to delete the unnecessary links. Please
read How to compare two columns in Excel and delete duplicates (highlight, color, move)
The best way is to merge two tables by domain name
This is the most advanced way and the one I personally prefer.
Suppose, you have a separate Excel worksheet with reference data for each domain you ever
worked with. This workbook keeps webmaster contacts for link exchange and the date when
your website was mentioned in this domain. There can also be types/subtypes of websites and
a separate column with your comments like on the screenshot below.
As soon as you get a new list of links you can match two tables by domain name and merge the
information from the domain lookup table and your new URLs sheet in just two minutes.
As a result you will get the domain name as well as the website category and your comments.
This will let you see the URLs from the list you need to delete and those you need to process.
Match two tables by domain name and merge data:
0. Download and install the latest version of Merge Tables Wizard for Microsoft Excel
This nifty tool will match and merge two Excel 2013-2003 worksheets in a flash. You can use
one or several columns as the unique identifier, update existing columns in the master
worksheet or add new from the lookup table. Feel free to read more about Merge Tables Wizard
on our website.
1. Open your URLs list in Excel and extract domain names as described above.
2. Select any cell in your table. Then go to the Ablebits Data tab and click on the Merge Two
Tablesicon to run the add-in.
3. Press the Next button twice and select your worksheet with the domains information as
theLookup Table.
5. Select what information about the domain you want to add to the URLs list and click Next.
6. Press the Finish button. When the processing is over, the add-in will show you a message
with the details of the merge.
Just a few seconds - and you get all information about each domain name at a glance.
You can download Merge Tables Wizard for Excel, run it on your data and see how useful it can
be.
If you are interested to get a free add-in for extracting domain names and subfolders of the root
domain (.com, .edu, .us etc.) from the URL list, simply drop us a comment. When doing this,
please specify your Excel version, e.g. Excel 2010 64-bit, and enter your email address in the
corresponding field (do not worry, it won't be displayed publically). If we have a decent number
of votes, we will create such and add-in and I let you know. Thank you in advance!
You may want to shade the rows in different colors based on the cell value in the Qty. column to
see the most important orders at a glance. This can be easily done using Excel Conditional
Formatting.
1. Start with selecting the cells the background color of which you want to change.
2. Create a new formatting rule by clicking Conditional Formatting > New Rule... on
the Home tab.
3. In the "New Formatting Rule" dialog window that opens, choose the option "Use a formula to
determine which cells to format" and enter the following formula in the "Format values where
Instead of C2, you enter a cell that contains the value you want to check in your table and put
the number you need instead of 4. And naturally, you can use the less (<) or equality (=) sign so
that your formulas will read =$C2<4 and =$C2=4, respectively.
Also, pay attention to the dollar sign $ before the cell's address, you need to use it to keep the
column letter the same when the formula gets copied across the row. Actually, it is what makes
the trick and applies formatting to the whole row based on a value in a given cell.
4. Click the "Format..." button and switch to Fill tab to choose the background color. If the
default colors do not suffice, click the "More Colors..." button to pick the one to your liking, and
You can also use any other formatting options, such as the font color or cells border on the
other tabs of the Format Cells dialog.
5. If this is how you wanted it and you are happy with the color, click OK to see your new
formatting in effect.
Now, if the value in the Qty. column is greater than 4, the entire rows in your Excel table will turn
blue.
As you can see, changing the row's color based on a number in a single cell is pretty easy in
Excel. Further on, you will find more formula examples and a couple of tips for more complex
scenarios.
How to apply several rules with the priority you need
In the previous example, you may want to highlight the rows with different values in
the Qty.column in different colors. For example, you can add a rule to shade the rows with
quantity 10 or greater, say, in pink. In this case, use the formula =$C2>9, and after your second
formatting rule is created, set the rules priority so that both of your rules will work.
1. On the Home tab, in the Styles group, click Conditional Formatting > Manage Rules... .
2. Choose "This worksheet" in the "Show formatting rules for" field. If you want to manage the
rules that apply to your current selection only, choose "Current Selection".
3. Select the formatting rule you want to be applied first and move it to the top of the list using
the arrows. The result should resemble this:
Click the OK button and the corresponding rows will immediately change their background color
based on the cell values that you specified in both formulas.
If an order is "Due in X Days", the background color of such rows will turn orange;
If an item is "Delivered", the entire row will be colored in green;
If an order is "Past Due", the row will turn red.
Naturally, the row color will change if the order status gets updated.
While the formula from our first example could work for "Delivered" and "Past
Due"(=$E2="Delivered" and =$E2="Past Due"), the task sounds a bit trickier for "Due in..."
orders. As you see, different orders are due in 1, 3, 5 or more days and the above formula won't
work because it is purposed for exact match.
In this case, you'd better use the =SEARCH formula like this =SEARCH("Due in", $E2)>0 that
works for the partial match as well. In the formula, E2 is the address of the cell that you want to
base your formatting on, the dollar sign ($) is used to apply the formula to the entire row,
and >0means that the formatting will be applied if the specified text ("Due in" in our case) is
found.
Tip: If you use >0 in the above formula, it means that the row will be colored no matter where
the specified value or text is located in the key cell. For example, the Delivery column (F) may
contain the text "Urgent, Due in 6 Hours", and this row will be colored as well.
If you want to change the color of rows where the contents of the key cell starts with the
indicated value or text, then you need to use =1 in the formula, e.g. =SEARCH("Due in",
$E2)=1. However, be very careful when using this kind of formula and ensure that there are no
leading spaces in the key column, otherwise you might rack your brain trying to figure out why
the formula does not work :) You can use this free tool to find and remove leading and trailing
spaces in your worksheets - Trim Spaces add-in for Excel.
Create three such rules following the steps from the first example, and you will have the below
table, as the result:
For example, we could create three such rules to shade only the cells in the "Order number"
column based on another cell value (values in the Delivery column).
And you can use the =AND formula, say, to change the background color of rows
with Qty. equal to or greater than 5 and equal to or less than 10: =AND($D2>=5, $D2<=10).
Naturally, you are not limited to using only 2 conditions in such formulas, you are free to use as
many as you need, e.g. =OR($F2="Due in 1 Days", $F2="Due in 3 Days", $F2="Due in 5
Days") and so on.
Tip: Now that you know how to color cells to differentiate between various types of values, you
may want to know how many cells are highlighted in a certain color and calculate the sum of
values in those cells. The good news is that you can automate this too and you will find the
solution in this article: How to count, sum and filter cells by color in Excel.
These are only a few of many possible ways to zebra stripe your Excel worksheets based on a
cell's value that will respond to change of data in that cell. If you need something different for
your data set, drop us a comment and we will try to figure this out.
0. If necessary, find and delete all duplicates from the table. You can first highlight the dupes
and delete them manually after looking through the values. Or you can remove all duplicates
with the help of the Duplicate Remover add-in.
1. Select the entire column where you need to avoid duplicates. Click on the first cell with data
keeping the Shift keyboard button pressed and then select the last cell. Or simply use the
combination of Ctrl + Shift + End. It is important to select the 1st data cell first.
Note: If your data are in a simple Excel range as opposed to a full-fledged Excel table, you need
to select all the cells in your column, even the blank ones, from D2 to D1048576
2. Go to Excel "Data" tab and click on the Data Validation icon to open the dialog box.
3. On the Settings tab, choose "Custom" from the Allow drop down list and
enter=COUNTIF($D:$D,D2)=1 into the Formula box.
Here $D:$D are the addresses of the first and the last cells in your column. Please pay attention
to the dollar signs that are used to indicate absolute reference. D2 is the address of the first
selected cell, it is not an absolute reference.
With the help of this formula Excel counts the number of occurrences of the D2 value in the
range D1:D1048576. If it is mentioned just once, then everything is fine. When the same value
appears several times, Excel will show an alert message with the text you specify on the "Error
alert" tab.
Tip: You can compare your column with another column to find duplicates. The second column
can be on a different worksheet or event workbook. For example, you can compare the current
column with the one that contains the blacklisted emails of customers
you don't won't to work with any longer. :) I will give more details about this Data Validation
option in one of my future posts.
4. Switch to the "Error alert" tab, and enter your text into the fields Title and Error message.
Excel will show you this text as soon as you try to enter a duplicate entry into the column. Try to
type the details that will be accurate and clear for you or your colleagues. Otherwise, in a month
or so you can forget what it means.
For example:
Title: "Duplicate email entry"
Message: "You have entered an email address that already exists in this column. Only unique
Warning: The buttons on the dialog will turn as Yes / No / Cancel. If you click Yes, the value you
enter will be added. Press No or Cancel to get back to editing the cell. No is the default button.
Information: The buttons on the alert message will be Ok and Cancel. If you click Ok (the
default one), a duplicate will be added. Cancel will take you back to the editing mode.
Note: I'd like to pay your attention again to the fact that the alert about a duplicate entry will
appear only when you try to enter a value into a cell. Excel will not find existing
duplicateswhen you configure the Data Validation tool. It will not happen even if there are more
than 150 dupes in your column. :).
Change the background color of cells based on value (dynamically) - The background
color will change automatically when the cell value changes.
Change a cell's color based on its current value (statically) - Once set, the background
color will not change no matter how the cell's value changes.
Change color of special cells (blanks / with errors / with formulas)
How to change a cell's color based on value in Excel dynamically
The background color will change dependent on the cell's value.
Task: You have a table or range of data, and you want to change the background color of cells
based on cell values. Also, you want the color to change dynamically reflecting the data
changes.
Solution: You need to use Excel conditional formatting to highlight the values greater than
X, less than Y or between X and Y.
Suppose you have a list of gasoline prices in different states and you want the prices greater
than USD 3.7 to be of the color red and equal to or less than USD 3.45 to be of the color green.
Note: The screenshots for this example were captured in Excel 2010, however the buttons,
dialogs and settings are the same or nearly the same in Excel 2007 and Excel 2013.
3. In the New Formatting Rule dialog box, select "Format only cells that contain" under
"Select a Rule Type" box in the upper part of the dialog box.
4. In the lower part of the dialog box under "Format Only Cells with section", set the rule
conditions. We choose to format only cells with a Cell Value - greater than - 3.7, as you can
Then click the Format... button to choose what background color to apply when the above
condition is met.
5. In the Format Cells dialog box, switch to the Fill tab and select the color of your choice, the
reddish color in our case, and click OK.
6. Now you are back to the New Formatting Rule window and the preview of your format
changes is displayed in the Preview box. If everything is Okay, click the OK button.
Since we need to apply one more condition, i.e. change the background of cells with values
equal to or less than 3.45 to the green color, click the New Rule button again and repeat steps 3
- 6 setting the required condition. Here is the Preview of our second conditional formatting rule:
When you are done, click the OK button. What you have now is a nicely formatted table that lets
you see the highest and lowest gas prices across different states at a glance. Lucky they are in
Texas :)
Tip: You can use the same method to change the font color based on the cell's value. To do
this, simply switch to the Font tab in the Format Cells dialog box that we discussed in step 5 and
choose your preferred font color.
If you need to color cells with a particular value, e.g. 50, 100 or 3.4, go to
the Home tab, Editinggroup, and click Find Select > Find....
Enter the needed values and click the Find All button.
Tip: Click the Options button in the right-hand part of the Find and Replace dialog to get a
number of advanced search options, such as "Match Case" and "Match entire cell content". You
can use wildcard characters, such as an asterisk (*) to find any string of characters or a
question mark (?) to find any single character.
In our previous example, if we needed to find all gas prices between 3.7 and 3.799, we would
specify the following search criteria:
Now select any of the found items in the lower part of the Find and Replace dialog window by
clicking on it and then press Ctrl+A to select all found entries. After that click the Close button.
This is how you select all cells with a certain value(s) using the Find All function in Excel.
However, what we actually need is to find all gas prices higher than 3.7 and regrettably
Excel's Find and Replace dialog does not allow for such things.
Luckily, there is another tool that can handle such complex conditions. The Select Special
Cellsadd-in lets you find all values in a specified range, e.g. between -1 and 45, get the
maximum / minimum value in a column, row or range, find cells by font color, fill color and much
more.
You click the Select by Value button on the ribbon and then specify your search criteria on the
add-in's pane, in our example we are looking for values greater than 3.7. Click the Select button
and in a second you will have a result like this:
If you are interested to try the Select Special Cells add-in, you can download an evaluation
version here.
Change the background color of selected cells using "Format Cells" dialog
Now that all cells with a specified value or values are selected (either by using Excel's Find and
Replace or Select Special Cells add-in) what is left for you to do is force the background color of
selected cells to change when a value changes.
Open the Format Cells dialog by pressing Ctrl+1 (you can also right click any of selected cells
and choose "Format Cells..." from the pop-up menu, or go to Home tab > Cells
group > Format > Format Cells...) and make all format changes you want. We will choose to
change the background color in orange this time, just for a change :)
If you want to alter the background color only without any other format changes, then you can
simply click the Fill color button and choose the color to your liking.
Unlike the previous technique with conditional formatting, the background color set in this way
will never change again without your notice, no matter how the values change.
Change background color for special cells (blanks, with formula errors)
Like in the previous example, you can change the background color of special cells in two ways,
dynamically and statically.
Use Excel formula to change background color of special cells
A cell's color will change automatically based on the cell's value.
This method provides a solution that you will most likely need in 99% of cases, i.e. the
background color of cells will change according to the conditions you set.
We are going to use the gas prices table again as an example, but this time a couple of more
states are included and some cells are empty. See how you can detect those blank cells and
change their background color.
1. On the Home tab, in the Styles group, click Conditional Formatting > New Rule... (see step 2
of How to dynamically change a cell color based on value for step-by-step guidance).
2. In the "New Formatting Rule" dialog, select the option "Use a formula to determine which
cells to format". Then enter one of the following formulas in the "Format values where this
formula is true" field:
3. Click the Format... button and choose the needed background color on the Fill tab (for
detailed instructions, see step 5 of "How to dynamically change a cell color based on value")
and then clickOK.
The preview of your conditional formatting rule will look similar to this:
4. If you are happy with the color, click the OK button and you'll see the changes immediately
applied to your table.
2. In the "Go to Special" dialog box, check the Blanks radio button to select all empty cells.
If you want to highlight cells containing formulas with errors, choose Formulas > Errors. As
you can see in the screenshot above, a handful of other options are available to you.
3. And finally, change the background of selected cells, or make any other format
customizations using the "Format Cells" dialog as described in Changing the background of
selected cells.
Just remember that formatting changes made in this way will persist even if your blank cells get
filled with data or formula errors are corrected. Of course, it's hard to imagine off the top of the
head why someone may want to have it this way, may be just for historical purposes :)
How to get the most of Excel and make challenging tasks easy
As an active user of Microsoft Excel, you know that it has plenty of features. Some of them we
know and love, others are a complete mystery for an average user and various blogs, including
this one, are trying to shed at least some light on them. But! There are a few very common tasks
that all of us have to perform daily and Excel simply does not provide any features or tools to
automate them or make an inch easier.
For example, if you need to check 2 worksheets for duplicates or merge rows from single or
different spreadsheets, it would take a bunch of arcane formulas or macros and still there is no
guarantee you would get the accurate results.
That was the reason why a team of our best Excel developers designed and created 20+ addins that we call the Ultimate Suite for Excel. These smart tools handle the most grueling,
painstaking and error-prone tasks in Excel and ensure quickly, neatly and flawless results.
Below is a short list of just some of the tasks the add-ins can help you with:
Regrettably, Excel does not provide any built-in tool to achieve this. Of course, there is
the Mergebutton ("Merge & Center" etc.), but if you select 2 adjacent cells in order to combine
them, as shown in the screenshot:
You will get the error message "Merging cells only keeps the upper-left cell value, and discards
the other values." (Excel 2013) or "The selection contains multiple data values. Merging into one
cell will keep the upper-left most data only." (Excel 2010, 2007)
Further in this article, you will find 3 ways that will let you merge data from several columns into
one without losing data, and without using VBA macro. If you are looking for the fastest way,
skip the first two, and head over to the 3rd straight away.
between the merged names, you can use any other symbol as a separator, e.g. a comma.
In a similar fashion, you can join data from several cells into one, using any separator of your
choice. For instance, you can combine addresses from 3 columns (Street, City, Zip) into one.
3. Copy the formula to all other cells of the Full Name column. For step-by-step instructions
please see how to enter the same formula into all selected cells at a time.
4. Well, we have combined the names from 2 columns in to one, but this is still the formula. If
we delete the First name and /or the Last name, the corresponding data in the Full Name
column will also be gone.
5. Now we need to convert the formula to a value so that we can remove unneeded columns
form our Excel worksheet. Select all cells with data in the merged column (select the first cell in
the "Full Name" column, and then press
Ctrl+Shift+ArrowDown).
Copy the contents of the column to clipboard (Ctrl + C or Ctrl + Ins, whichever you prefer), then
right click on any cell in the same column ("Full Name" ) and select "Paste Special" from the
context menu. Select the "Values" radio button and click OK.
6. Remove the "First Name" & "Last Name" columns, which are not needed any longer. Click
the column B header, press and hold Ctrl and click the column C header (an alternative way is
to select any cell in column B, press Ctrl + Space to select the entire column B, then press Ctrl +
Shift + ArrowRight to select the whole column C).
After that right click on any of the selected columns and choose Delete from the context menu:
Fine, we have merged the names from 2 columns into one! Though, it required quite a lot of
effort and time :(
2. Copy data to clipboard (press Ctrl + C or Ctrl + Ins, whichever you prefer).
3. Open Notepad: Start-> All Programs -> Accessories -> Notepad.
4. Insert data from the clipboard to the Notepad (Press Ctrl + V or Shift + Ins)
5. Copy tab character to clipboard. Press Tab right in Notepad, press Ctrl + Shift + LeftArrow,
then press Ctrl + X.
6. Replace Tab characters in Notepad with the separator you need.
Press Ctrl + H to open the "Replace" dialog box, paste the Tab character from the clipboard in
the "Find what" field, type your separator, eg. Space, comma etc. in the "Replace with" field.
Press the "Replace All" button; then press "Cancel" to close the dialog box.
7. Press Ctr + A to select all the text in Notepad, then press Ctrl + C to copy it to Clipboard.
8. Switch back to your Excel worksheet (press Alt + Tab), select just B1 cell and paste text from
the Clipboard to your table.
9. Rename column B to "Full Name" and delete the "Last name" column.
There are more steps than in the previous option, but believe me or try it yourself, this way is
faster. The next way is even faster and easier :)
Join columns using the Merge Cells add-in for Excel
The quickest and easiest way to combine data from several Excel columns into one is to
useMerge Cells add-in for Excel.
With the Merge Cells add-in you can combine data from several cells using any separator you
like (e.g.: carriage return or line break). You can join values row by row, column by column or
merge data from the selected cells into one without losing it.
How to combine two columns in 3 simple steps
0. Download and install Merge Cells for Excel.
1. Select all cells from 2 columns that you want to merge, and go to the "Ablebits.com Data" tab.
Click the "Merge cells" button to run the add-in.
3. Several simple clicks and we've got two columns merged without entering any formulas or
copy/pasting.
To finish up, rename column B to "Full Name" and delete column "C", which is not needed any
longer.
Much easier than the two previous ways, isn't it? :)
You may also be interested in:
How to merge rows in Excel 2010 and 2013 without losing data