PDA

View Full Version : Function to convert text into a number



Djblois
12-19-2008, 08:34 AM
I am writing a formula but I am missing one part, I need to convert text into a number. Is there a function that will do this?

Here is what I have:

=IF(LEN(A7678)=5,VLOOKUP(LEFT(A7678,1),Country!A:B,2,FALSE),VLOOKUP(LEFT(A7 678,2),Country!A:B,2,FALSE))

What I want it to do is if the code is 5 digits then do a vlookup off the first digit, otherwise do it off the first two digits. However, whenever you do left on a number, it pulls it out as text - not a number. So I need a function that will convert it into a number. Thank you for help.

Bob Phillips
12-19-2008, 08:42 AM
Try

=If(LEN(A7678)=5,VLOOKUP(--LEFT(A7678,1),Country!A:B,2,False),VLOOKUP(--LEFT(A7678,2),Country!A:B,2,False))

Djblois
12-19-2008, 08:49 AM
xld,

Thank you that worked perfectly. What do the -- mean?

Bob Phillips
12-19-2008, 10:05 AM
Coerce the expression into a (not inverted sign) number.