Remove space and trailing text from number

G

gossamer

Hi ng
Using xl xp pro.
Receive text file wish to convert to xl

Some data comes in like this:
12 oz

Would like to trim " oz" w/o quotes
So all I'm left with is 12

Here's my formula:
=IF(ISNUMBER(A3),A3,(VALUE(LEFT(A3,FIND(" ",A3)-1))))
Works fine.

However other data comes in this format:
12+z
How could I re-work my formula to take care of either condition

Remaining value beginning from left of string could be any number of digits


Also:
If col a contains text I receive #value! error
I take care of this with
=IF(ISNUMBER($F1037),$F1037,1)
But it would be more elegant if I could incorp all into 1 formula.

tia.
goss
 
B

Bernard V Liengme

Hello,
This VBA function will do it

Function tonumber(mytext)
temp = Val(mytext)
tonumber = temp
End Function

If you need help in using it please get back to me
Bernard
 

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