Quick, clean, and to the point

FILTER to remove columns

Excel formula: FILTER to remove columns
Generic formula 

To filter columns, supply a horizontal array for the include argument. In the example shown, the formula in I5 is:


The result is a filtered set of data that contains only columns A, C, and E from the source data.


Although FILTER is more commonly used to filter rows, you can also filter columns, the trick is to supply an array with the same number of columns as the source data. In this example, we construct the array we need with boolean logic, also called Boolean algebra.

In Boolean algebra, multiplication corresponds to AND logic, and addition corresponds to OR logic. In the example shown, we are using Boolean algebra with OR logic (addition) to target only the columns A, C, and E like this:


After each expression is evaluated, we have three arrays of TRUE/FALSE values:


The math operation (addition) converts the TRUE and FALSE values to 1s and 0s, so you can think of the operation like this:


In the end, we have a single horizontal array of 1s and 0s:


which is delivered directly to the FILTER function as the include argument:


Notice there are 6 columns in the source data and 6 values in the array, all either 1 or 0. FILTER uses this array as a filter to include only columns 1, 3, and 5 from the source data. Columns 2, 4, and 6 are removed. In other words, the only columns that survive are associated with 1s.

With the MATCH function

Applying OR logic with addition as shown above works fine, but it doesn't scale well, and makes it impossible to use a range of values from a worksheet as criteria. As an alternative, you can use the MATCH function together with the ISNUMBER function like this to construct the include argument more efficiently:


The MATCH function is configured to look for all column headers in the array constant {"a","c","e"} as shown. We do it this way so that the result from MATCH has dimensions compatible with the source data, which contains 6 columns. Notice also that the third argument in MATCH is set as zero to force an exact match.

After MATCH runs, it returns an array like this:


This array goes directly into ISNUMBER, which returns another array:


As above, this array is horizontal and contains 6 values separated by commas. FILTER uses the array to remove columns 2, 4, and 6.

With a range

Since the column headers are already on the worksheet in the range I4:K4, the formula above can easily be adapted to use the range directly like this:


The range I4:K4 is evaluated as {"a","c","e"}, and behaves just like the array constant in the formula above.

Dynamic Array Formulas are available in Excel 365 only.
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 200+ Excel Shortcuts

Get over 200 Excel shortcuts for Windows and Mac in one handy PDF.