parsing complex numbers

L

levent

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
 
M

merjet

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
 
N

Nigel

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
 
L

levent

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




.
 

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