By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,307 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,307 IT Pros & Developers. It's quick & easy.

Excel: How do I Display Specific Text in a Cell if the Value is 0

P: 5
I use in Excel the formula =NETWORKDAYS(A2;B2)for calculating the number of days between the dates in cells A2 and B2. The result is in Cell C2
However, I would like to display a Predifined Text in C2 if the result is zero.

I suppose The Predifined Text can be in the formula bar in a sort of If statement.
If 0 ,OK will be displayed in cell C2)
It does not matter what in the cell will be displayed if result is not zero.

I assume the cell C2 format must then be Text or General
Normally I use Number for C2.

May be, I also can or need to use an other formula?? DateDiff or something like that?? I do not know all possibilities.

Who can help me
Jan 11 '12 #1
Share this Question
Share on Google+
8 Replies


Rabbit
Expert Mod 10K+
P: 12,421
Sounds like you're looking for the IF() function
Jan 11 '12 #2

100+
P: 332
Expand|Select|Wrap|Line Numbers
  1. =if(NETWORKDAYS(A2;B2)=0,"OK",NETWORKDAYS(A2;B2))
Jan 11 '12 #3

NeoPa
Expert Mod 15k+
P: 31,707
This can be done as a simple Format property. Something like :
Expand|Select|Wrap|Line Numbers
  1. 0;-0;"Some text"
The format property can be found in the Properties window of cells, rows and/or columns, etc.

PS. @Mario. There is no worksheet function IIF() in Excel. IF() has the same use as IIf() does in VBA though.
Jan 11 '12 #4

100+
P: 332
@NeoPa. I am doing to much VBA, I have to go back to spreadsheets. I would have never thought of your answer. Love it.
Jan 11 '12 #5

NeoPa
Expert Mod 15k+
P: 31,707
Thanks Mario. I always appreciate the support of you guys who do so much to keep things going here :-)

NB. It's important to understand that the underlying data doesn't change. It's still a zero. All that changes is what is displayed (IE. The .Text property as opposed to the .Value).
Jan 11 '12 #6

P: 5
I have tried this, but I can not get it working.
I noted that thereis an IF statement

IF(logical_test[value_if_tue];[value_if_false])

But I do not know how to use this for my problem
Jan 11 '12 #7

P: 9
see Mariostg reply and enter :
Expand|Select|Wrap|Line Numbers
  1. =IF(NETWORKDAYS(A2;B2)=0,"OK",NETWORKDAYS(A2;B2)
in cell C2. It should work. Then just copy the formula down the column.
Jan 11 '12 #8

NeoPa
Expert Mod 15k+
P: 31,707
Peter Dam:
I have tried this, but I can not get it working.
You've tried what? In the circumstances (the thread to date) this makes little sense.

NB. Please read all the replies. You could save wasting much of your time (and ours of course).
Jan 11 '12 #9

Post your reply

Sign in to post your reply or Sign up for a free account.