How to Fix value after every n columns in Excel

In this article, we will learn How to Fix value after every 3 columns in Excel.

Scenario:

In simple words, while working with column filled data. Sometimes, we need to fix the values after every n columns. We need to fix a value after every given number of times. See the below formula to calculate using the formula.

How to solve the problem?

For this article we will be needing the use the following functions:

  1. IF function
  2. MOD Function
  3. COLUMN function

Now we will make a formula out of these functions. Here we will give the row and we need to place values after every n times, n is given with number.

Syntax formula:

=IF( MOD( COLUMN( cell ) - 1 , n ) = 0 , fixed_value ,50)

Cell : where formula is used

fixed_value : fixed value in cell

50 : rest values.

Example:

All of these might be confusing to understand. So, let's test this formula via running it on the example shown below. Here we have fixed value and a value of n as 4 i.e. fixed value occurs at every 4th column.

Formula:

=IF( MOD( COLUMN(E5) - 1 , 4 ) = 0 , $A$2 , 50 )

E5 : cell where formula is used

-1 : offset value, number of columns between the left of the sheet to the cell used.

4 : after every n columns, n = 4

$A$2 : fixed value "NA" in A2 cell. ($A$2 cell freezes the cell when formula extended to other cells)

Explanation:

  1. COLUMN function returns the column index of the cell reference used.
  2. -1 offset value to use first reference cell as first cell for the range.
  3. 4 value of n, fixed value to occur after every 4th column.
  4. MOD function checks the remainder COLUMN(E5) - 1 with 4 for every value in range and returns TRUE or FALSE.
  5. IF function returns Fixed value if TRUE or else it returns 50 as number value.

Here the array to the function is given as cell_reference. Press Enter to get the column values.

The formula returns 50, as it is only 1st cell for the range. Here -1 is the offset value. Use Ctrl + R to copy the formula from one cell to other along the columns.

Here we have the fixed value after every 4 columns. This function is usually used to construct a structure where known values should be there. Like taking a attendance of class in school,  marking P where present and sundays at the interval of 7 as Sunday (fixed value at each interval of 7) and leaves or absentees can be marked manually.  

As you can see from the above formula returns an array of values with condition having Fixed value after every n columns. Here are some observational results using the above formula used.

Notes:

  1. The value if true & value if False argument can be customized as per required results.
  2. Use Ctrl + R instead of Ctrl + D. Ctrl + R is copy the formula along columns and Ctrl + D to copy formula along rows.
  3. Check the brackets and commas in the formula if any error occurs. 
  4. Do not forget to freeze the fixed value cell on the first formula. You can freeze cell by hord code values using ("fixed_value") or by having cursor on the cell refernce in the formula press F4 ($A$2) or by placing dollar char using keyboard.
  5. You can place at every alternate row using n = 2 in the formula. 

Hope this article about How to Fix value after every n columns in Excel is explanatory. Find more articles on summing functions here. If you liked our blogs, share it with your fristarts on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com.

Related Articles

How to use the SUMPRODUCT function in Excel: Returns the SUM after multiplication of values in multiple arrays in excel.

How to use the WEEKDAY function in Excel: Weekday function returns the week number for the given date in excel.

SUM if date is between : Returns the SUM of values between given dates or period in excel.

Sum if date is greater than given date: Returns the SUM of values after the given date or period in excel.

2 Ways to Sum by Month in Excel: Returns the SUM of values within a given specific month in excel.

How to Sum Multiple Columns with Condition: Returns the SUM of values across multiple columns having condition in excel.

Popular Articles

50 Excel Shortcut to Increase Your Productivity : Get faster at your task. These 50 shortcuts will make you work even faster on Excel.

How to use the VLOOKUP Function in Excel : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets. 

How to use the COUNTIF function in Excel : Count values with conditions using this amazing function. You don't need to filter your data to count specific values. Countif function is essential to prepare your dashboard.

How to Use SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Youtube