Complex Numbers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I do complex numbers in Visual Basic for Excel. I
installed the analysis add in so I can now do it in
Excel. However, I want Visual Basic to manipulate
complex numbers in my program. This is part of my basic
code that doesn't work. Thanks for the help.

wks_W.Range("AY" & i).Value = WorksheetFunction.complex
(1, 2)

or

wks_W.Range("AY" & i).Value = complex(1, 2)
 
Here are two ways.

In the vba editor, if you do "Not" have the following checked...
Tools|References... and a check on "atpvbaen.xls" then here is one way that
I use:

Sub Demo1()
Dim x
Const ImAbs As String = "ATPVBAEN.XLA!ImAbs"
x = Run("ImABS", "3+4i")
End Sub


However, if you do select "atpvbaen.xls", then it's much easier:

Sub Demo2()
Dim x
x = ImAbs("3+4i")
'or your example:
Range("A1") = Complex(1, 2)
End Sub


HTH
Dana DeLouis
 
Back
Top