SheetSense

Remainder with MOD: even, odd and every Nth row

MOD returns the remainder after division. A remainder of 0 when dividing by 2 means the number is even.

fx
=IF(MOD(A2,2)=0,"Even","Odd")

The sheet: Column A holds whole numbers such as order numbers. You want to label each one even or odd.

How it works, step by step

  1. 01MOD(A2,2) divides A2 by 2 and returns the remainder, 0 or 1.
  2. 02=0 tests for no remainder.
  3. 03IF labels the row Even or Odd. The same pattern with MOD(ROW(),5)=0 flags every fifth row.

The same logic in four tools

Excel
=IF(MOD(A2,2)=0,"Even","Odd")
Google Sheets
=IF(MOD(A2,2)=0,"Even","Odd")
SQL
SELECT order_no,
       CASE WHEN order_no % 2 = 0 THEN 'Even' ELSE 'Odd' END AS parity
FROM orders;
Python (pandas)
import numpy as np

df["parity"] = np.where(df["order_no"] % 2 == 0, "Even", "Odd")

Mistakes that break it

  • !For negative numbers MOD takes the sign of the divisor in Excel, Sheets and pandas, but the SQL % operator in PostgreSQL takes the sign of the dividend. MOD(-3,2) is 1 in a sheet and -1 in PostgreSQL.
  • !Dividing by 0 returns #DIV/0!.
  • !Decimals give fractional remainders, so MOD(2.5,2) is 0.5, not 0 or 1.

Common questions

How do I shade every other row?
Use a conditional formatting rule with the formula =MOD(ROW(),2)=0.
Can I use it with dates?
Yes, since dates are numbers. MOD(A2,7) gives a day-of-week position, though WEEKDAY is clearer.

Got a version of this with your own ranges?

Paste it into the free translator and get the same breakdown for your exact formula. To run it against a real file, upload the CSV and describe the formula you need in a sentence.