if statements and formulas

M

Motaad

I am trying to write an "if" statement such as
if a column cell equals the number 7 substract the date in one column from a
date in another column

=if(e2=7,h2-f2,0) - h2 being a date column and f2 being a date column

Unfortunately it always gives me a zero even if there is a 7 in column e2.
 
S

Sandy Mann

Motaad,

I only get a 0 when E2 holds a text representation of a 7. Test E2 witht he
formula =ISTEXT(E2)

If it is text reformat the cell as General and re-enter the 7

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

[email protected]
[email protected] with @tiscali.co.uk
 
G

Gord Dibben

Are you sure the value in E2 is a number and not text.

Enter this in a cell =ISNUMBER(E2) do you get TRUE or FALSE?


Gord Dibben MS Excel MVP
 
Top