SCAN

Array & Advanced
(4.8/5)

Scans an array by applying a LAMBDA function to each value and returns an array that has each intermediate value

Interactive Formula Tester

=SCAN("")

Complete Theory & Understanding

Master the fundamentals of Excel SCAN function

Core Concept

The SCAN function applies a LAMBDA function to each element of an array, returning an array of all intermediate accumulated values. It is useful for tracking the progression of calculations.

Why Use SCAN?

  • SCAN returns all intermediate values, unlike REDUCE which returns only the final result
  • SCAN requires a LAMBDA function that takes accumulator and current value parameters
  • Use SCAN to track how calculations progress through an array

Key Characteristics

Intermediate Results

SCAN returns all intermediate values, unlike REDUCE which returns only the final result

Example 1

LAMBDA Integration

SCAN requires a LAMBDA function that takes accumulator and current value parameters

Example 2

Progressive Calculation

Use SCAN to track how calculations progress through an array

Example 3

Function Anatomy

=SCAN(parameters...)
Required
Parameters:

Function-specific parameters

Returns
Return Value:

Function-specific return type

Primary Use Cases

Intermediate Results

SCAN returns all intermediate values, unlike REDUCE which returns only the final result

LAMBDA Integration

SCAN requires a LAMBDA function that takes accumulator and current value parameters

Progressive Calculation

Use SCAN to track how calculations progress through an array

Theory Summary

Precise

Exact matching required

Position-Based

Returns numeric position

Error-Safe

Handles missing text gracefully

Syntax & Parameters

=SCAN(initial_value, array, lambda)
Optional
initial_value:

Optional. The initial value for the accumulator

Required
array:

The array to scan

Required
lambda:

A LAMBDA function that takes accumulator and current value, returns new accumulator

Returns
Return Value:

An array with all intermediate accumulated values

Description: SCAN([initial_value], array, lambda)

Interactive Examples

Basic SCAN function

Basic SCAN function

""
=SCAN(0, A1:A3, LAMBDA(acc, val, acc+val))
Array of running sums

Scans A1:A3 and returns running sum at each step

VBA Implementation & Automation

SCAN VBA Example

VBA implementation for SCAN.

Sub SCANExample()
    Dim result As Variant
    ' Note: SCAN is not available in VBA, use alternative methods
    ' This is a conceptual example
    result = Application.WorksheetFunction.Scan(0, Range("A1:A3"), "LAMBDA(acc, val, acc+val)")
    MsgBox "SCAN result: " & result
End Sub

Business Applications

Running calculations

Running calculations

SCAN([initial_value], array, lambda)

Progressive aggregation

Progressive aggregation

SCAN([initial_value], array, lambda)

Cumulative operations

Cumulative operations

SCAN([initial_value], array, lambda)

Data tracking

Data tracking

SCAN([initial_value], array, lambda)

Intermediate results

Intermediate results

SCAN([initial_value], array, lambda)

Common Issues & Solutions

SCAN not working

SCAN not working

Solution: Ensure the LAMBDA function syntax is correct and takes accumulator and value parameters

Unexpected array size

Unexpected array size

Solution: Check that the input array and LAMBDA logic are appropriate for your use case

Performance Tips & Best Practices

⚡ Performance Optimization

  • SCAN is efficient for progressive calculations
  • Use with LAMBDA for complex accumulation logic
  • Consider using REDUCE if you only need the final result