VBA complex numbers

L

Levent

Hello

I was just wondering if there is a data type called
complex (i.e. for operations with complex numbers) in any
version of VBA for Excel.

I am aware that you can use Excel functions for this, but
I was wondering if VBA can deal with it also.

because if i use the Excel functions in VBA. i have to do

Range("something").formula = "IMPRODUCT(whatever)"

and have to read that again back into VBA

somevariable = Range("something")
(if anyone can think of a more efficient way, that would
also do)
 
T

Tom Ogilvy

Actually you don't have to do that

sStr = Application.Run("ATPVBAEN.XLA!IMPRODUCT","3+4i","5-3i")

so to demonstrate from the immediate window:

sStr = Application.Run("ATPVBAEN.XLA!IMPRODUCT","3+4i","5-3i")
? sStr
27+11i

This assume the Analysis Toolpak - VBA has been selected in Tools=>Addins.

If you create a reference to ATPVBAEN.XLA you can call it like a built in
VBA function

sStr = IMPRODUCT("3+4i","5-3i")

but to the best of my knowledge, VBA itself does not support complex
numbers.
 

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