ZetCode

Excel COMPLEX Function

last modified October 5, 2026

The COMPLEX function converts real and imaginary coefficients into a complex number in Excel. Complex numbers are used in engineering, physics, and advanced mathematics. This tutorial provides a comprehensive guide to using the COMPLEX function with detailed examples. You'll learn basic syntax, how the result text is formatted, edge cases such as zero and unit coefficients, and how to feed the result into Excel's other complex number functions.

COMPLEX Function Basics

The COMPLEX function creates a complex number from real and imaginary coefficients. Complex numbers are expressed in the form x + yi or x + yj. Excel uses either "i" or "j" as the imaginary unit and returns the result as text, not as a number.

Component Description
Function Name COMPLEX
Syntax =COMPLEX(real_num, i_num, [suffix])
Arguments real_num (required), i_num (required), suffix (optional)
Return Value Text representation of a complex number

This table breaks down the essential components of the COMPLEX function. It shows the function name, syntax format, required and optional arguments, and the type of value returned.

Argument Meaning
real_num The real coefficient. Required. It can be a literal, a cell reference, or an expression that returns a number.
i_num The imaginary coefficient. Required. It is the number that multiplies the imaginary unit in the result.
suffix The imaginary unit: lowercase "i" or "j". Optional; when omitted, Excel uses "i".

The suffix is case sensitive. Only lowercase "i" and "j" are accepted; uppercase "I" or "J" returns #VALUE!. Functions that combine two or more complex numbers, such as IMSUM, require every value to use the same suffix.

Basic COMPLEX Example

This example demonstrates the simplest use of the COMPLEX function with basic numeric inputs.

Basic COMPLEX formula
=COMPLEX(3, 4)

This formula creates a complex number with 3 as the real part and 4 as the imaginary part. The result will be "3+4i". When the suffix is omitted, Excel defaults to using "i" as the imaginary unit.

COMPLEX with Different Suffix

This example shows how to specify a different suffix for the imaginary unit. Engineers often use "j" instead of "i".

COMPLEX with "j" suffix
=COMPLEX(5, 2, "j")

This formula creates a complex number with 5 as the real part and 2 as the imaginary part, using "j" as the suffix. The result will be "5+2j". The suffix must be enclosed in quotes and can only be "i" or "j".

COMPLEX with Negative Imaginary Part

This example demonstrates how COMPLEX handles negative imaginary coefficients. The function automatically formats the output correctly.

COMPLEX with negative imaginary
=COMPLEX(7, -3)

This formula creates a complex number with 7 as the real part and -3 as the imaginary part. The result will be "7-3i". The function automatically uses the correct operator (+ or -) based on the sign of the imaginary coefficient.

COMPLEX with Zero Real Part

This example shows how COMPLEX handles cases where the real part is zero. The output format changes to show only the imaginary part.

COMPLEX with zero real part
=COMPLEX(0, 5)

This formula creates a complex number with 0 as the real part and 5 as the imaginary part. The result will be "5i". When the real part is zero, Excel omits it from the display, showing only the imaginary component.

COMPLEX with Zero Imaginary Part

This example demonstrates how COMPLEX handles cases where the imaginary part is zero. The output shows only the real number.

COMPLEX with zero imaginary part
=COMPLEX(4, 0)

This formula creates a complex number with 4 as the real part and 0 as the imaginary part. The result will be "4". When the imaginary part is zero, Excel returns just the real number as a text string.

COMPLEX with Unit and Negative Coefficients

Excel shortens the result whenever a coefficient is zero or the imaginary coefficient is 1 or -1. Knowing these compact forms matters, because the text that COMPLEX returns is exactly what the other complex number functions parse.

Formula Result Note
=COMPLEX(0,0) 0 Both parts are zero
=COMPLEX(0,1) i Unit imaginary part loses its digit
=COMPLEX(0,-1) -i The sign is kept
=COMPLEX(4,1) 4+i Real part plus a unit imaginary part
=COMPLEX(4,-1) 4-i Negative unit imaginary part
=COMPLEX(0,-5) -5i Zero real part with a negative imaginary
=COMPLEX(-3,4) -3+4i Negative real part
=COMPLEX(-3,-4) -3-4i Both parts negative

Notice that the sign of the imaginary part is always written explicitly, so COMPLEX(7,-3) becomes 7-3i rather than 7+-3i. The same rule applies to the real part: COMPLEX(-3,4) returns -3+4i. These short forms are valid input for the IM functions, so IMABS("i") returns 1 and IMREAL("-3-4i") returns -3.

COMPLEX with Decimal Values

This example shows how COMPLEX handles decimal numbers for both real and imaginary parts. The function maintains the decimal precision in the output.

COMPLEX with decimal values
=COMPLEX(2.5, 1.75)

This formula creates a complex number with 2.5 as the real part and 1.75 as the imaginary part. The result will be "2.5+1.75i". The function preserves the decimal places from both input values in the output string.

COMPLEX in Array Formulas

COMPLEX expects scalar coefficients, so a bare range has to be coerced before it can be processed element by element. Adding zero to each range turns it into an array of numbers, and the formula then spills one complex number per row in Excel 365, Excel 2021, and Excel 2024.

A B C
1 2 =COMPLEX(A1:A3+0, B1:B3+0)
3 4 3+4i
5 6 5+6i

The table shows real parts in column A and imaginary parts in column B. The formula in C1 returns 1+2i and spills down to C3.

COMPLEX array formula
=COMPLEX(A1:A3+0, B1:B3+0)

This array formula creates three complex numbers: "1+2i", "3+4i", and "5+6i". Without the +0 coercion the range is treated as a single value and the formula returns one #VALUE! error. In Excel 2019 and earlier, confirm the formula with Ctrl+Shift+Enter so that it is evaluated as an array.

COMPLEX with Other Complex Functions

COMPLEX produces text, but that text is understood by every function in Excel's complex number family. This makes it easy to build values from separate real and imaginary parts and then operate on them.

COMPLEX feeding the IM functions
=IMSUM(COMPLEX(1,2), COMPLEX(3,4))        ' 4+6i
=IMPRODUCT(COMPLEX(1,2), COMPLEX(3,4))    ' -5+10i
=IMABS(COMPLEX(3,4))                      ' 5
=IMREAL(COMPLEX(3,4))                     ' 3
=IMAGINARY(COMPLEX(3,4))                  ' 4

IMSUM adds the two complex numbers, and IMPRODUCT multiplies them: (1+2i)(3+4i) = -5+10i. IMABS returns the magnitude sqrt(3^2+4^2) = 5, while IMREAL and IMAGINARY pull the two coefficients back out as ordinary numbers. All of these functions accept either the text produced by COMPLEX or complex-number text typed directly, such as "3+4i".

COMPLEX Errors and Troubleshooting

Most COMPLEX problems come from non-numeric coefficients or from a suffix that Excel does not accept. The table below lists the common causes and their fixes.

Cause Symptom Fix
real_num is non-numeric text #VALUE! error Pass a number, or a cell that contains one
i_num is non-numeric text #VALUE! error Pass a number, or a cell that contains one
suffix is neither "i" nor "j" #VALUE! error Use exactly "i" or "j"
suffix is uppercase "I" or "J" #VALUE! error Switch to lowercase; the suffix is case sensitive
Mixed suffixes in IMSUM or IMPRODUCT #VALUE! error Use the same suffix for every complex number
A required argument is omitted #VALUE! or a "too few arguments" warning Supply both real_num and i_num
A coefficient cell is blank The blank is treated as 0 Fill the cell, or coerce it with +0 if a blank is not wanted
A whole range is passed to COMPLEX A single #VALUE! error Coerce the range with +0 so it spills element by element

The COMPLEX function is essential for working with complex numbers in Excel. It turns separate real and imaginary coefficients into the exact text format that IMSUM, IMPRODUCT, IMABS, IMREAL, and IMAGINARY expect. Remember the two details that trip people up most: the result is text, so it cannot be used in ordinary arithmetic, and the suffix is case sensitive and must match across values that are combined. Master these rules, and COMPLEX becomes a reliable foundation for engineering and mathematical work in spreadsheets.

Author

My name is Jan Bodnar, and I am a passionate programmer with extensive programming experience. I have been writing programming articles since 2007. To date, I have authored over 1,400 articles and 8 e-books. I possess more than ten years of experience in teaching programming.

List all Excel Formulas.