#1   Report Post  
Posted to microsoft.public.excel.misc
hans
 
Posts: n/a
Default format cell

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
sweet_dreams
 
Posts: n/a
Default format cell

you should use IF function. for details check excel help or look he

spreadsheets.about.com/ cs/excelfunction1/a/iffunction.htm

http://pubs.logicalexpressions.com/P...cle.asp?ID=225

regards,
sweet_dreams

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ruth Allen
 
Posts: n/a
Default format cell

Dear hans,

I think I know what's happening so check this out. The '0' is your negative
result in the format you defined. In your formula, you could further define
a negative result to be formatted differently than the positive result. Let
me know if this answer is not clear or you need more help.
--
Ruth Allen
EMBRACING TECHNOLOGY
embracingtech.com


"hans" wrote:

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?

  #4   Report Post  
Posted to microsoft.public.excel.misc
CLR
 
Posts: n/a
Default format cell

=IF(B1<=0,0,B1) formatted as date dd-mm-yy


Vaya con Dios,
Chuck, CABGx3



"hans" wrote:

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?

  #5   Report Post  
Posted to microsoft.public.excel.misc
Lancslad
 
Posts: n/a
Default format cell

To force a zero in A1, you could multiply the value by the result of an
argument. So in A1 enter =B1*(Date1<Date2). So if Date1 is less than Date2,
A1 will equal B1. If not, the result will be multiplied by zero, so that will
set the result of the calc to zero.

Hope that helps.

"hans" wrote:

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?



  #6   Report Post  
Posted to microsoft.public.excel.misc
Lancslad
 
Posts: n/a
Default format cell

Sorry Hans, my last post wasn't what you wanted.

I'd be tempted to do a conditional format so that if the value = 0, then the
font colour matches the background.

"Lancslad" wrote:

To force a zero in A1, you could multiply the value by the result of an
argument. So in A1 enter =B1*(Date1<Date2). So if Date1 is less than Date2,
A1 will equal B1. If not, the result will be multiplied by zero, so that will
set the result of the calc to zero.

Hope that helps.

"hans" wrote:

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?

  #7   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default format cell

On Mon, 23 Jan 2006 03:51:02 -0800, "hans"
wrote:

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?


The problem is that A1 is formatted as "date". Therefore when the value is 0,
you will see the result you get.

Try this custom format instead:

Format/Cells/Number/Custom Type: [0]m/d/yyyy;[<0]\0;0

With this format, you won't even need to test for negative values in your
formula in A1.


--ron
  #8   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default format cell

On Mon, 23 Jan 2006 09:45:27 -0500, Ron Rosenfeld
wrote:

On Mon, 23 Jan 2006 03:51:02 -0800, "hans"
wrote:

I have a cell A1 in which I want to print a date dd-mm-yy. This cell is
depending on another cell B1 . In this cell I calculate the number of days by
distracting one date from another. If the number of days is positive A1
should read a date dd-mm-yy, if the number of days is negative A1 should read
0.
A1 gives me 0-1-1900
How can I get 0 in A1 ?


The problem is that A1 is formatted as "date". Therefore when the value is 0,
you will see the result you get.

Try this custom format instead:

Format/Cells/Number/Custom Type: [0]m/d/yyyy;[<0]\0;0

With this format, you won't even need to test for negative values in your
formula in A1.


--ron


I should rephrase my last statement:

"With this format, you won't even need to test for negative values in your
formula in A1" **IF** all you are concerned about is the appearance and not the
contents of the cell.

If you want a zero to be stored in A1, then you will need your IF formula, as
the formatting only changes the display of the cell and not the actual
contents.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bring the cell format along with the cell value from a reference c Lorrie Horgen Excel Worksheet Functions 1 January 20th 06 09:52 PM
Reference Cell in custom format???? lil_ern63 Excel Discussion (Misc queries) 3 September 1st 05 02:27 PM
Why does my format keep changing in the cell? Denise Excel Discussion (Misc queries) 0 August 30th 05 04:23 PM
how do I format a cell reference to move as source changes KGray Excel Worksheet Functions 1 August 13th 05 12:41 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM


All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"