BITOR Function

Combines the bits of two numbers (bitwise OR).

Category

Engineering

Available in

Excel 2013+, Microsoft 365

Returns

A whole number

Want to practice BITOR in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

BITOR compares two numbers in binary and returns a 1 in every position where either number has a 1.

Use it to switch flags on: BITOR(code, 2) turns on the 2 switch and leaves everything else as it was.

Syntax

=BITOR(number1, number2) Explain

Arguments

ArgumentRequired?What it does
number1YesThe first whole number.
number2YesThe second whole number.

Examples

Example 1 — How the bits combine

Each row combines the two numbers bit by bit; the answer is shown as an ordinary decimal number.

C2fx=BITOR(A2,B2)
ABC
1Number 1Number 2OR
2231031
3537
48412
=BITOR(A2,B2) Explain

Example 2 — Give everyone Edit access

Edit is the 2 switch. People who already had it keep the same code.

C2fx=BITOR(B2,2)
ABC
1PersonCodeNew code
2Ana1315
3Ben33
4Di810
=BITOR(B2,2) Explain

Common mistakes

  • #NUM! Both numbers must be whole numbers from 0 up to 2^48 − 1 (281,474,976,710,655). Negative numbers, decimals and bigger values return #NUM!.
  • Using + instead. Adding 2 to a code that already has Edit (3 + 2 = 5) turns Edit off and Approve on by mistake. BITOR never does.

Notes

  • Permission flags are a classic use: give each option a power of two (View = 1, Edit = 2, Approve = 4, Admin = 8) and store a person's access as one number — 13 means View + Approve + Admin.
  • Related functions: BITAND, BITXOR, DEC2BIN.
Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.