To get the max of every nth column, you can use a formula based on MAX, FILTER, MOD, SEQUENCE, and COLUMNS. In the example shown, the formula in O5 is:


where n is the named range M2. With 3 in cell M2, the formula returns 17, the maximum value of the 3rd, 6th, 9th, and 12th values in B5:M5. If n is changed to another value, the formula will recalculate. See below for alternatives and a formula that will work in older versions of Excel.

Generic formula



In this example, the goal is to calculate the maximum value of every "nth" column in a row of data, where n is a variable entered in the named range M2. This problem can be solved in several ways, as explained below. The explanation below also includes a formula that will work in older versions of Excel, before dynamic array formulas were introduced.


A classic solution to "nth" problems is to use the MOD function to check a numeric array for a remainder of zero after dividing by n. This is the approach in the worksheet shown, there the formula in cell O5, copied down, is:


At a high level, the FILTER function is configured to retrieve only the nth values of interest using logic created with MOD and SEQUENCE. The result from FILTER is returned to MAX, which returns the maximum value as a final result. Working from the inside out, the SEQUENCE function is configured to generate a numeric array like this:


Because there are 12 columns in the range B5:M5, SEQUENCE returns an 1 x 12 array like this:


This array is returned to the MOD function as the number argument, with n provided as the divisor. The result from MOD is then compared to zero:


With the number 3 in cell M2 for n, MOD returns an array like this:


Note that every 3rd value is zero. When this array is compared to zero, the result is an array of TRUE and FALSE values like this:


Notice that every 3rd value is now TRUE. This array is returned directly to the FILTER function as the include argument. With array given as B5:M5, FILTER returns every 3rd value in B5:M5 directly to MAX like this:


The MAX function then returns 17 as a final result.


An alternative approach is to use the CHOOSECOLS function with the SEQUENCE function like this:


This formula calculates the numeric indices of target nth values directly, then requests just those values with the CHOOSECOLS function. The SEQUENCE function is configured to return the numeric indexes of every nth value like this:


The rows argument is left empty. The columns argument is calculated by dividing the number of columns by n. Both start and step are assigned the value n. With 12 columns in B5:M5, and the number 3 for n, this simplifies to:


The result is a numeric array of "target nth values" like this:


This array is returned directly to the CHOOSECOLS function as the second argument:


The CHOOSECOLS function then returns the values at these locations in an array to MAX:


The MAX function returns 17 as before.

All in one formulas

If desired, you can adapt the formulas above to single, all-in-one formulas based on the BYROW function like this:


The first formula uses the SEQUENCE and MOD approach, the second formula uses the SEQUENCE and CHOOSECOLS approach. Both formulas will return the max values for nth columns for all rows at once.

Legacy Excel

In older versions of Excel without dynamic array formulas like FILTER and SEQUENCE, you can use an array formula like this:


This is an array formula and must be entered with control + shift + enter in older versions of Excel.

At a high level, this formula uses the IF Function together with the MOD and COLUMN functions to "cancel out" values not in nth columns, then runs MAX on the result. The key is this snippet:


The COLUMN function is used to get a set of "relative" column numbers as explained in detail here. The result is a numeric array that starts with the number 1:


This array goes into the MOD function as the number argument:


where n is the value to use for "nth". The MOD function returns the remainder for each column number divided by n. When n = 3, MOD will return an array like this:


Note that zeros appear for columns 3, 6, 9 and 12, corresponding to every 3rd column. This array is compared to zero with the logical expression =0 to force a TRUE when the remainder is zero and a FALSE when not. These values go into the IF function as the logical test. The IF function then "filters" results so only values in the original range in nth columns make it into the final array. Other values become FALSE. The result is delivered to the MAX function:


The MAX function automatically ignores FALSE values and returns 17 as a final result.

Max of every other column

To get the maximum value in every other column, you can make a small adjustment to the formula when needed. To get the maximum value in even columns, use the original formula with 2 as n:


To get the maximum number in odd columns use 2 for n and compare the result to 1:


In older versions of Excel, you can use these generic formulas:

{=MAX(IF(MOD(COLUMN(A1:Z1)-COLUMN(A1)+1,2)=0,rng))} // even columns
{=MAX(IF(MOD(COLUMN(A1:Z1)-COLUMN(A1)+1,2)=1,rng))} // odd columns

These are array formulas and must be entered with control + shift + enter in older versions of Excel.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

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.