I am writing an Excel spreadsheet and one of the things I am having it do is calculate the number of days until a future date. So I have a column with a formula to subtract todays date from whatever date I enter in another column. It works fine, the only problem is that the formula column displays -39,155 in every cell all the way down until I fill in a date in the other column. Is there any way to hide the result of the calculation until I fill in the other date and the formula actually calculates a valid answer?
You could just hide the whole column.
Or don’t populate the column with the formula. Wait until a date is entered, and then copy the formula to that row.
It’s a valid answer (2/2/07 = 39,115 for example), but I can see that it doesn’t look nice. It sounds like you want to display the results only if they’re equal to or greater than zero. I’ll poke around and see what I can find out, or one of the Excel gurus will show up.
OK, here’s one way. Highlight the cells/column and then hit Format–Conditional Formatting. Fill out the conditions to say Cell Value Is – Less Than – 0 – and then hit the Format button. Choose Color of white (assuming the background of the sheet is white). This will “hide” the results less than zero but show zero and greater in black or whatever your text color is.
Thanks. That’s perfect.
Can also build the condition into a formula. For instance, if the formula that is producing the negative number of days is A1-B1, you could use this: =IF(A1-B1<0,"",A1-B1).
IMHO this is the preferred solution and much better than mucking around with conditional formatting. With formatting, if someone highlights a block of “empty” cells they will see the large value. Not pretty.
I agree yours is better; the only defense is that when they do see the ugly values, it proves the formula has been copied there, rather than showing nothing in the cell.
This is the way I’d do it. Though it has always annoyed me that I need to use one of my seven nested functions to hide unwanted values in a cell.
Depends on how it’s going to be used, and what you are expecting the user to do. If you have a user sophisticated enough to be alarmed at an “empty” cell, and possibly try to type something into it, then they are probably sophisticated enough to see that there is a formula in the formula bar. If you can’t trust the user in this case, I would take the further steps of locking the cells and protecting the sheet.