Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MS Excel provides a set of functions to work with complex numbers. When displaying real numbers, one can set the decimal places precision from the Format Cells dialog. However, it does not work for complex numbers.

How can I set the displayed precision of a complex number? Is there a custom template I can use for that?

0.98078528040323+0.195090322016128i --> 0.980+0.195i

share|improve this question
up vote 1 down vote accepted

You could wrap your complex formula's in a UDF that does the formatting:

Function FormatComplex(r As Variant, fmt As String) As String
    With Application.WorksheetFunction
        FormatComplex = Format(.ImReal(r), fmt) & Format(.Imaginary(r), fmt) & "i"
    End With
End Function

Call it like



share|improve this answer
Thanks. I guess this is as good as it can get, although it make the formulation of the cell ugly. – ysap Apr 14 '12 at 3:17

To achieve this by formula (in a different cell), you can use the following, where your unformatted complex number is in A1:

share|improve this answer
Thanks. I was hoping to avoid formulas like this, to occupy another cell. It also messes up the layout of my spreadsheet (this is basically regarding hundreds of cells..) – ysap Apr 13 '12 at 20:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .