ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   parsing complex numbers (https://www.excelbanter.com/excel-programming/305043-parsing-complex-numbers.html)

levent

parsing complex numbers
 
can anyone think of an easy way to parse the real and
imaginary part of a complex number into two separate cells
in excel (using excel or VB)

2.111+0.34i = 2.111 0.34
-2.11-0.34i = -2.11 -0.34

i thought of cycling through the word using mid function
and checking for ascii values

thanks


Dana DeLouis[_3_]

parsing complex numbers
 
=IMREAL(A1)
&
=IMAGINARY(A1)

HTH
Dana DeLouis


"levent" wrote in message
...
can anyone think of an easy way to parse the real and
imaginary part of a complex number into two separate cells
in excel (using excel or VB)

2.111+0.34i = 2.111 0.34
-2.11-0.34i = -2.11 -0.34

i thought of cycling through the word using mid function
and checking for ascii values

thanks




merjet

parsing complex numbers
 
can anyone think of an easy way to parse the real and
imaginary part of a complex number into two separate cells
in excel (using excel or VB)

2.111+0.34i = 2.111 0.34
-2.11-0.34i = -2.11 -0.34

i thought of cycling through the word using mid function
and checking for ascii values


There are worksheet functions for this -- IMAGINARY and
IMREAL. You may need to check the Analysis ToolPak add-in
to use them.

HTH,
Merjet




Nigel

parsing complex numbers
 
Try this

Call ExtractRI("string value in here")

Function ExtractRI(x As String)
r = Val(x)
i = Val(Right(x, Len(x) - Len(Str(Val(r)))))
End Function

Cheers
Nigel

"levent" wrote in message
...
can anyone think of an easy way to parse the real and
imaginary part of a complex number into two separate cells
in excel (using excel or VB)

2.111+0.34i = 2.111 0.34
-2.11-0.34i = -2.11 -0.34

i thought of cycling through the word using mid function
and checking for ascii values

thanks




levent

parsing complex numbers
 
yeah, i should have thought of that

thanks
-----Original Message-----
Try this

Call ExtractRI("string value in here")

Function ExtractRI(x As String)
r = Val(x)
i = Val(Right(x, Len(x) - Len(Str(Val(r)))))
End Function

Cheers
Nigel

"levent" wrote in

message
...
can anyone think of an easy way to parse the real and
imaginary part of a complex number into two separate

cells
in excel (using excel or VB)

2.111+0.34i = 2.111 0.34
-2.11-0.34i = -2.11 -0.34

i thought of cycling through the word using mid function
and checking for ascii values

thanks



.



All times are GMT +1. The time now is 03:07 PM.

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