if statements and formulas

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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

(e-mail address removed)
(e-mail address removed) with @tiscali.co.uk
 
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
 

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

Back
Top