convert text to number

  • Thread starter Thread starter Herb
  • Start date Start date
H

Herb

Hi, I have a sheet that I use to keep track of vacations.
In it, if a cell has the entry of "Vac", I want the
assumption it is for 8 hours in the cell below, so I have
a formula like this: =IF(ISTEXT(L5),"8.0",""). It works
OK. (The idea is that most of the time it will be 8 hours,
users can change it if required).

Problem is when I add all the Vac cells in VB code, it
treates the entries in the IF cells as String so
concatinates the numbers. I have the cell defined as
numbers, the variable in code is defined as integer.

If I change the '8.0' that the IF statement generates with
8, the macro works as advertised.

Any help is appreciated...........Herb
 
Herb,

You could change your formula:
=IF(ISTEXT(L5),8.0,"")

Or within VB change your string to a value.
FRom the immediate window assuming that your original formula
is in cell L4

?val(range("L4"))

John
 
Back
Top