Networkdays function

J

Jenn

Here is the formula I am using right now:

=NETWORKDAYS(H8,F8)

But, if F8 is blank, how can I get this formula to also
leave the answer blank? In other words, I only want the
answer if both H8 and F8 are populated with dates.

Thank you!
 
N

Norman Harker

Hi Jenn!

Try:

=IF(F8="","",NETWORKDAYS(H8,F8))

But note here that you will get the dreaded #VALUE! if F8 is not blank
but contains text.

The trouble is that Excel does not have an ISDATE function. However
you can easily roll your own because VBA does have one. Just put the
following in a Module:

Function ISADATE(MyCell As Range)
ISADATE = IsDate(MyCell)
End Function

Now you can use:

=IF(ISADATE(F8),NETWORKDAYS(H8,F8),"")


--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
K

Ken Wright

:) Hey there stranger - Hasn't been the same without you. And the next time
you mention how we are doing in the cricket, I'm just going to shout 'Goooooooo
Johnny Wilkinson' ;-)
 
N

Norman Harker

Hi Ken!

Back after a very heavy semester. But feeling a bit rusty! Must put
some Single Malt into the system.

As long as you don't mention India we'll get on just fine! But with
our first string bowlers all out, we couldn't expect much different.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
H

Harlan Grove

...
...
The trouble is that Excel does not have an ISDATE function. However
you can easily roll your own because VBA does have one. Just put the
following in a Module:

Function ISADATE(MyCell As Range)
ISADATE = IsDate(MyCell)
End Function
...

UDFs are rather slow compared to built-in worksheet functions. A few built-in
worksheet functions could be used to do this.

(ISNUMBER(DATEVALUE(X))+ISNUMBER(FIND(CELL("Format",X),"D1 D2 D3 D4 D5"))>0)

This reproduces the results from VBA's IsDate function when X is a range. Note
that neither approach works for standard date arithmetic. The UDF chokes on
anything other than ranges, and if its argument type is changed to variant, it
returns False for ISADATE(TODAY()), which is nonobvious. The built-in formula
approach won't even accept nonrange X in the CELL function.
 

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

Similar Threads

Conditional Formatting Formula 2
Need help with a formula 3
Zero as a value 9
Multiple If Statements 3
Creating a Function in Excel 2003 2
numbers, text 1
NETWORKDAYS 2
SumProd from 2 columns and date range 6

Top