ExcelBanter

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

levent

Complex numbers in VBA (Excel(
 
would anyone know if one can use complex data type in VBA
(Excel). i know that you can do operations with comlex
numbers using Excel's Engineering formula package, but I
would prefer it if VBA was able to handle it directly.

also does it matter the version (i would prefer Excel 97,
but if not Excel 2002)



Tom Ogilvy

Complex numbers in VBA (Excel(
 
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
...
would anyone know if one can use complex data type in VBA
(Excel). i know that you can do operations with comlex
numbers using Excel's Engineering formula package, but I
would prefer it if VBA was able to handle it directly.

also does it matter the version (i would prefer Excel 97,
but if not Excel 2002)





levent

Complex numbers in VBA (Excel(
 
that is quite helpful, thanks

-----Original Message-----
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
...
would anyone know if one can use complex data type in

VBA
(Excel). i know that you can do operations with comlex
numbers using Excel's Engineering formula package, but I
would prefer it if VBA was able to handle it directly.

also does it matter the version (i would prefer Excel

97,
but if not Excel 2002)




.



All times are GMT +1. The time now is 06:42 PM.

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