Complex Numbers

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)
 
D

Dana DeLouis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top