Search code examples
excel-formulaworksheet-function

Function I can use to stop negative numbers and #value in networkdays function


I have attempted to stop negative numbers and #value from appearing in a networkdays function. I want to calculate the networkdays but not count the first day. I tried researching the possible functions that would solve this and came up with this:

=IFERROR(IF(NETWORKDAYS(E9,F9,MenuData!G3:G22)<0,"",NETWORKDAYS(E9,F9,MenuData!G3:G22)-1),0)

It does show a blank cell on the rows with negative numbers and the negative numbers are because there is only a value in cell E or F. But on rows where there are two dates, it makes the cell 0.


Solution

  • I solved it. Here's what I did in case someone else has the same problem I had (I am still learning):

    =IFERROR(IF(AH7="",0, IF(NETWORKDAYS(C7,AH7,MenuData!$G$3:$G$22)<0, 0, (NETWORKDAYS(C7,AH7,MenuData!$G$3:$G$22)-1))),0)

    This avoids negative numbers due to having blank cells in the spreadsheet and stops errors (#VALUE) in case there are N/A where the dates should be.