This formula combines the two ranges provided (E5:F9 and H5:I10), by appending the second range to the first range, and returns an array of values that spill into B5:C15. The third argument provides a default value to use when the formula runs into errors combining ranges, for example when ranges have different column counts. This is a custom function created with LAMBDA, based on several Excel functions, including INDEX, SEQUENCE, IFERROR, ROWS, COLUMNS, and MAX. Holding the whole thing together are LAMBDA and LET: This formula is based on a simplified formula explained here. It’s a good example of how the LAMBDA function and LET function work well together. Inside the LET function, the first six lines of code simply assign values to variables. Once values are assigned, these variables drive the output of the function. The core logic of the formula, the code that builds the combined array, is here: This code can be tricky to read, especially if you’re new to LAMBDA functions and dynamic array formulas in general. With line breaks added for readability, it’s tempting to read it like a loop, with rowindex as an incrementing counter, but in reality, rowindex is not one value, but an array of 11 values, created with the SEQUENCE function earlier: The IF function tests the values in rowindex all at once. If rowindex is less than or equal to the count of the rows in range1 (5), INDEX fetches rows from range1. If the rowindex is greater than 5, INDEX fetches rows from range2. If we expand the values of the variables, the code looks something like this: This code can be tested directly on a worksheet, and it will return the same result as the formula. The array that IF and INDEX create is assigned to the variable result, which is returned as a final value by the formula through the IFERROR function. This is done as a way to catch errors that occur when ranges of different column counts are combined. For example if you combine a two-column range with a one-column range, INDEX will throw an error when it tries to get values from column 2, since column 2 does not exist. In this case, the default value will be output instead of an error.

### Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.