ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA complex numbers (https://www.excelbanter.com/excel-programming/304712-vba-complex-numbers.html)

Levent

VBA complex numbers
 
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)



Tom Ogilvy

VBA complex numbers
 
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.

--
Regards,
Tom Ogilvy

"Levent" wrote in message
...
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)






All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com