Contact

MOD Function in ONLYOFFICE Spreadsheet Editor: Syntax and Examples

Math and Trigonometry Beginner ONLYOFFICE Spreadsheet Editor

Find leftovers after division, group repeating records and detect divisible quantities.

Verification status: Three signed-integer remainder cases checked in ONLYOFFICE Desktop Editors Community 10.0.0.169 on Linux x64; additional examples independently calculated. Other clients and builds untested. How formula examples are checked

MOD returns the remainder after division. With 17 items and a pack size of five, the remainder is two because 17=3×5+2. It does not return the three full packs.

Availability and version history

  • Introduced: The original introduction release and date are not established by the checked references.
  • Availability: Documented in current ONLYOFFICE help and observed in Desktop Editors Community 10.0.0.169. This is not a final supported-version endpoint.
  • Scope: Native observations cover Linux x64 only. Docs, mobile, earlier versions and other desktop platforms remain separately untested.
  • Checked: October 14, 2026, against the official MOD reference, pinned source and the explicitly identified native cases. Additional worked results were independently calculated.

Syntax and a zero divisor

=MOD(number, divisor)

Both arguments are required. The official MOD reference defines the remainder and explicitly specifies #DIV/0! when the divisor is zero. The error is not a numeric result meaning no leftovers.

The official illustration puts 65 in A1 and 7 in A2, with =MOD(A1,A2) in C2 returning 2. Keep those two inputs in separate rows if reproducing that exact source example.

Complete packing worksheet

Create PackingRemainders, with A1:F7 available. Enter Items and Per pack in A1:B1, then enter all six numeric input pairs:

Row A: items B: per pack Expected C
2 17 5 2
3 21 6 3
4 20 4 0
5 0 7 0
6 7 0 #DIV/0!
7 14 5 4

Put Remainder in C1. Enter =MOD(A2,B2) in C2 and fill through C7. The numeric outputs are arithmetic checks; the row-6 error is specifically documented by ONLYOFFICE. Row 6 deliberately preserves the invalid source value so the error is visible.

Guard the dashboard without reporting a false zero

Label D1 Packing status. Enter this in D2 and fill all the way through D7, including the zero-divisor row:

=IF(B2=0,"Fix pack size",IF(MOD(A2,B2)=0,"Exact packs","Leftovers"))

The expected labels are Leftovers, Leftovers, Exact packs, Exact packs, Fix pack size, Leftovers. The guard reports a data problem instead of replacing it with zero leftovers. These inputs use nonnegative item counts and nonnegative pack sizes; a real packing model should also reject negative or fractional sizes.

For a separate valid-row check, put =INT(A2/B2) in E2 for 3, and =E2*B2+C2 in F2 for 17. Do not copy that unguarded division into row 6. INT supplies the floored quotient for positive pack sizes, and IF supplies the labels.

Negative signs in the tested desktop build

Three numeric-reference cases were run in ONLYOFFICE Desktop Editors Community 10.0.0.169 on Linux x64: MOD(-3,2)=1, MOD(3,-2)=-1 and MOD(-17,-5)=-2. The result workbook preserved the inputs and formulas. These are exact-build observations, not a test of every Docs, mobile or historical version.

The pinned official implementation calculates number-divisor*floor(number/divisor). For the ordinary integer cases below, this means a nonzero remainder has the divisor’s sign. This source statement is tied to the inspected revision; the help page itself does not spell out that convention.

On a separate SignedRemainders sheet, put Number, Divisor, Remainder, Floored quotient and Reconstruction in A1:E1. Enter -3 and 2, 3 and -2, and -17 and -5 in A2:B4. In C2 enter =MOD(A2,B2), D2 =INT(A2/B2), and E2 =B2*D2+C2, then fill through row 4.

Row Expected C Expected D Expected E
2 1 -2 -3
3 -1 -2 3
4 -2 3 -17

These are signed arithmetic controls, not examples of negative physical pack sizes. Replacing the floored quotient with truncation can produce a different remainder convention.

Advanced: one-based repeating positions

Create CycleLabels, with headers Item number, Position and Next-cycle position in A1:C1. Put the positive cycle length 5 in E1. Enter 16,17,18,19,20,21 in A2:A7.

  • B2: =MOD(A2-1,$E$1)+1
  • C2: =MOD(A2+$E$1-1,$E$1)+1

Fill B2:C2 through row 7. Both columns give 1,2,3,4,5,1. For item 17 the position is two, matching the earlier literal calculation. Subtracting one before MOD and adding one afterward changes zero-based remainders into labels one through five.

This rule assumes positive integer item numbers and a positive integer cycle length. It does not establish a calendar schedule or validate arbitrary decimal inputs. Keep the cycle size anchored when filling formulas.

Precision, input types and portability

Fractional inputs can have fractional remainders, but finite precision matters near exact multiples. A displayed zero is not sufficient evidence that the stored result is zero. The native checks here use small integers and do not establish decimal-boundary behavior.

Text, empty references, Boolean inputs, error cells and extreme values require separate validation. Use ABS for unsigned magnitude and TRUNC for truncation; neither is interchangeable with MOD’s signed remainder calculation.