Returns the number of areas in a reference. An area is a cell range or a single cell. Essential for counting ranges, validating multi-range references, and working with non-contiguous selections.
Master the fundamentals of Excel AREAS function
The AREAS function counts the number of separate ranges (areas) in a reference. An area is defined as a continuous range of cells or a single cell. This function is particularly useful for validating multi-range references, checking named ranges, and working with non-contiguous selections.
Returns number of separate ranges
Single cell counts as one area
Works with named ranges containing multiple areas
Useful for validating reference structure
Function-specific parameters
Function-specific return type
Validate whether reference contains multiple areas
Analyze named ranges with multiple areas
Count areas in dynamically created references
Check structure of multi-range references
Exact matching required
Returns numeric position
Handles missing text gracefully
=AREAS(reference)A reference to a cell or range of cells. Can be a single reference or multiple references separated by commas (e.g., A1:B5, C1:D5).
Number of areas (ranges) in the reference
Description: Counts the number of separate ranges or areas in a reference
Count areas in single range
Returns 1 because A1:C10 is a single continuous range (one area).
Use AREAS function in VBA to count ranges
' Basic AREAS in VBA
Dim areaCount As Integer
areaCount = Application.WorksheetFunction.Areas(Range("A1:C10"))
' Returns: 1
' AREAS with multiple ranges
Dim multiRange As Range
Set multiRange = Union(Range("A1:B5"), Range("C1:D5"))
areaCount = Application.WorksheetFunction.Areas(multiRange)
' Returns: 2
' Validate reference structure
Sub CheckAreas()
Dim ref As Range
Set ref = Range("A1:B5, C1:D5")
Dim areaCount As Integer
areaCount = Application.WorksheetFunction.Areas(ref)
If areaCount > 1 Then
MsgBox "Multiple areas detected: " & areaCount
Else
MsgBox "Single area"
End If
End Sub
' Count areas in named range
Sub CountNamedRangeAreas()
Dim namedRange As Range
On Error Resume Next
Set namedRange = Range("MyNamedRange")
If Not namedRange Is Nothing Then
Dim areaCount As Integer
areaCount = Application.WorksheetFunction.Areas(namedRange)
Debug.Print "Named range has " & areaCount & " area(s)"
End If
End SubValidate whether reference contains multiple areas before processing
Count areas in named ranges for validation
Process differently based on number of areas
Check areas in dynamically created references
AREAS returns #REF! when reference is invalid
=AREAS((A1:B5, C1:D5))Solution: Verify the reference exists and is valid. Check for deleted cells, invalid named ranges, or incorrect reference syntax. Ensure multi-range references use proper syntax: (Range1, Range2).
AREAS always returns 1 even with multiple ranges
Use: =AREAS((A1:B5, C1:D5)) not =AREAS(A1:B5, C1:D5)Solution: For multiple ranges, use parentheses: (Range1, Range2). Without parentheses, Excel may interpret as a single range or formula error.
AREAS doesn't work correctly with named range
=AREAS(INDIRECT("MyNamedRange"))Solution: Verify named range exists and contains valid references. Use Name Manager to check named range definition. Ensure named range references are properly formatted.