How to use the AREAS function
What is the AREAS function?
The AREAS function returns the number of cell ranges and single cells in the specified argument.
Table of Contents
1. Introduction
What is a cell reference?
A cell reference in Excel is a way to identify and refer to a specific cell or range of cells within a spreadsheet. Cell references are fundamental to Excel's functionality, allowing users to create dynamic, interconnected spreadsheets.
What is the cell reference structure?
It depends if the cell reference points to a single cell or a cell range containing multiple cells. A single cell reference typically consists of a column letter followed by a row number (e.g., A1, B2, C3).
A cell range reference points to multiple cells, for example: A1:B10. Note that the colon separates the first cell reference and the second cell reference. The first cell reference indicates the top-left cell in the specified cell range, while the second cell reference denotes the bottom-right cell in that same range. These two cell references determines the height in rows and width in columns, of the cell range. Cell range references are used in functions that perform calculations or operations on a group of cells, rather than just a single cell.
Both single cell and multi-cell references can also include sheet names for referencing cells in other worksheets. For example, Sheet!A1 or Sheet2!B2:B10. Note that Excel requires an exclamation mark between the sheet name and the cell reference. You can find the Sheet names your workbook contains, at the very bottom to the left. Single quotation marks are used if the worksheet name contains a space character, example: 'Budget 2027'!B3
What are the different cell reference types?
- Relative: The cell reference changes when the cell is copied or moved. For example: A1
- Absolute: The cell reference is fixed and doesn't change when copied. The dollar signs lets you specify which part of the cell reference you want to be abolute. For example: $A$1
- Mixed: One part fixed, one part relative. $A1 or A$1
When are cell references used?
In formulas to perform calculations using values from other cells. For data validation, conditional formatting, and other Excel features. To link data between different sheets or workbooks.
What is a 3d reference?
In Excel, 3D references refer to the ability to reference cells or ranges across multiple worksheets within the same workbook. This can be useful when you need to perform calculations or operations that involve data from different sheets. Most Excel functions do not readily accept 3D references, which are references that point to the same cell or range across multiple sheets. The SUM, AVERAGE, COUNT, and FREQUENCY functions allow 3d references as arguments.
How to create a 3d-reference? To create a 3D reference, you use the following syntax: =SUM(Sheet1:Sheet3!A1:A10)
This formula will sum the values in the range A1 to A10 across the worksheets Sheet1, worksheets in between, and Sheet3. 3D references can use both relative and absolute references. For example:
- Relative reference: =SUM(Sheet1:Sheet3!A1:A10)
- Absolute reference: =SUM(Sheet1:Sheet3!$A$1:$A$10)
3D references are limited to the current workbook. You cannot create 3D references that span multiple workbooks. Using 3D references can be particularly useful when you have a large dataset spread across multiple worksheets and need to perform calculations or analyses that involve data from different sheets. This can help streamline your workflow and make your spreadsheets more efficient and organized.
Can the AREAS function work with 3d-ranges?
No, the AREAS function can not work with 3d-ranges. It returns a #VALUE! error.
What is a named range?
A named range in Excel is a way to assign a descriptive name to a cell or a range of cells. This can be very useful for making your spreadsheets more organized and easier to understand. Using named ranges can be a powerful tool for organizing and managing your Excel data, especially in large or complex workbooks. They can help you write more readable and maintainable formulas, and make it easier to work with your data.
You can define a named range by selecting the cells you want to name, then going to the Formulas tab and press with left mouse button oning on "Define Name". You can then enter a descriptive name for the range, such as "TaxCode" or "InventoryQuantity".
Once you have defined a named range, you can use it in formulas and functions just like you would use a cell reference. For example, you can use the named range in a formula like this: =SUM(InventoryQuantity). Named ranges can also be used in functions, such as VLOOKUP(lookup_value, SalesData, column_index, [range_lookup]).
Named ranges make your formulas and functions more self-explanatory and easier to understand. If the location of the data changes, you only need to update the named range definition rather than having to update all the formulas that reference the data. Named ranges can be used in a variety of contexts, such as in data validation rules, conditional formatting, and data connections.
Named ranges can be defined at the workbook level, which means they are available across all worksheets in the workbook. You can also define named ranges at the worksheet level, which means they are only available on the specific worksheet where they are defined.
Can the AREAS function work with named ranges?
Yes, the AREA function can work with named ranges. See an example in section 3 below.
How does a cell reference to a cell range look like?
A colon separates the start reference and the end reference. The start reference must be the top left cell in the cell range and subsequently the end reference must be the bottom right cell in the cell range. B3:G7 is an example of a cell reference to a cell range.
What does a cell reference to a single cell look like?
For example, B3 is a cell reference to a single cell.
2. Syntax
AREAS(reference)
reference | Required. A reference to a cell(s) or a cell range(s). |
Use parentheses to include multiple arguments as a single argument, see the example below.
3. Example 1
The image above shows the AREAS function in cell range B3:B6 and the formula text in cells C3:C6.
Formula in cell B3:
The formula in cell B3 returns 1 which represents the count of cell references in the argument E3:E4. This cell reference points to a cell range containing two cells.
The AREAS function is one of a few functions that allow the union operator comma , and a beginning and ending parentheses. The following formula demonstrates the use of a set of parentheses to include multiple cell references. Other functions that allow union operators are LARGE, COUNT, COUNTA, SMALL, LARGE, MIN, MAX, and AVERAGE functions.
The formula above is in cell B4 and it returns 3 which represents three cell references in (E4:E5, G3, E7:G9). The formula in cell B5 is much like the formula in cell B4 but it returns two instead of three. The argument is (E5:E6, E2:G6) which contains two cell references.
Formula in cell B6:
This formula contains a named range that contains (N16:N17,P15,N19:P21,L20:J22). The formula returns 4 which represents the number of cell references in (N16:N17,P15,N19:P21,L20:J22).
4. AREAS Function not working
The DAY function returns #NAME? error if you misspell the function name or use an invalid cell reference.
4.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
4.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue.
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference E3:E4000000000 converted to hard-coded value using the F9 key. The AREAS function requires valid cell references which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
4.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
5. How to count cells in a cell reference
The formula below returns the total number of cells in the specified range.
Formula in cell B3:
This formula calculates the total number of cells in the range B3:V16 by multiplying the number of rows (14) by the number of columns (21), resulting in a total of 294 cells. This type of formula can be useful when you need to quickly determine the size or dimensions of a range of cells in an Excel spreadsheet.
Explaining formula
Step 1 - Count rows in cell range
The ROWS function calculate the number of rows in a cell range.
Function syntax: ROWS(array)
ROWS(B3:V16) returns 14.
Step 2 - Count columns in cell range
The COLUMNS function calculates the number of columns in a cell range.
Function syntax: COLUMNS(array)
COLUMNS(B3:V16) returns 21.
Step 3 - Count columns in cell range
The asterisk lets you multiply numbers in an Excel formula.
ROWS(B3:V16)*COLUMNS(B3:V16)
becomes
14*21 equals 294 cells in cell range B3:V16.
6. How to count cells in multiple cell references
Cells B3 to B5 contain different cell references with variable sizes. The Excel 365 formula in cell B8 counts the cells for each cell reference and returns a total.
Formula in cell B8:
This formula does the following:
For each row in the range B3:B5, it calculates the number of cells in that row by multiplying the number of columns by the number of rows. It then sums up all these cell counts to get the total number of cells in the range B3:B5.
Explaining formula
Step 1 - Convert text string to ref
The INDIRECT function returns the cell reference based on a text string and shows the content of that cell reference.
Function syntax: INDIRECT(ref_text, [a1])
INDIRECT(a)
Step 2 - Count columns in ref
The COLUMNS function calculates the number of columns in a cell range.
Function syntax: COLUMNS(array)
COLUMNS(INDIRECT(a))
Step 3 - Count rows in ref
The ROWS function calculate the number of rows in a cell range.
Function syntax: ROWS(array)
ROWS(INDIRECT(a))
Step 4 - Multiply rows and columns
The asterisk lets you multiply numbers in an Excel formula.
COLUMNS(INDIRECT(a))*ROWS(INDIRECT(a))
Step 5 - Construct LAMBDA function
The BYROW function requires a LAMBDA function to work properly.
The LAMBDA function build custom functions without VBA, macros or javascript.
Function syntax: LAMBDA([parameter1, parameter2, …,] calculation)
LAMBDA(a,COLUMNS(INDIRECT(a))*ROWS(INDIRECT(a)))
Step 6 - Iterate refs row by row
The BYROW function puts values from an array into a LAMBDA function row-wise.
Function syntax: BYROW(array, lambda(array, calculation))
BYROW(B3:B5,LAMBDA(a,COLUMNS(INDIRECT(a))*ROWS(INDIRECT(a))))
Step 7 - Calculate a total
The SUM function allows you to add numerical values, the function returns the sum in the cell it is entered in. The SUM function is cleverly designed to ignore text and boolean values, adding only numbers.
Function syntax: SUM(number1, [number2], ...)
SUM(BYROW(B3:B5,LAMBDA(a,COLUMNS(INDIRECT(a))*ROWS(INDIRECT(a)))))
becomes
SUM({23; 45; 200})
and returns 268
Useful resources
AREAS function - Microsoft
AREAS function
Functions in 'Lookup and reference' category
The AREAS function function is one of 25 functions in the 'Lookup and reference' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form