ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   if statements and formulas (https://www.excelbanter.com/excel-worksheet-functions/134261-if-statements-formulas.html)

Motaad

if statements and formulas
 
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

Don Guillett

if statements and formulas
 
e7 is probably text so
="7" or
=if(value(e2)=7,h2-f2,0)

--
Don Guillett
SalesAid Software

"Motaad" wrote in message
...
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




Sandy Mann

if statements and formulas
 
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


with @tiscali.co.uk


"Motaad" wrote in message
...
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




Gord Dibben

if statements and formulas
 
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

On Fri, 9 Mar 2007 15:04:03 -0800, Motaad
wrote:

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.




All times are GMT +1. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com