#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Array Formula

Can anyone tell what I'm doing wrong here? If (on another sheet) IDTest =
$A$2:$A2, BegDateTest = $B$2:$B$2, and FinDateTest = $C$2:$C$2 the following
formula evaluates to 23. If IDTest = $A$3:$A3, BegDateTest = $B$3:$B$3, and
FinDateTest = $C$3:$C$3 the formula evaluates to 0. However, if IDTest =
$A$2:$A3, BegDateTest = $B$2:$B$3, and FinDateTest = $C$2:$C$3 the formula
evaluates to -68. I would expect 0 + 23. Anyone know why it isn't
evaluating to 23?

=SUM(IF((BegDateTestD1)+(FinDateTest<=C1)0,0,(ID Test=A2)*NETWORKDAYS(MAX(C1,BegDateTest),MIN(D1,Fi nDateTest))))

Any suggestions would be appreciated. Thanks.

Erin
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Array Formula

I tried getting rid of the IF as well with the same result. The values in
A2, C1 and D1 are 02548, 12/31/07 and 1/31/08, repectively while the second
sheet looks like this.

ID Beg Date Fin Date
02548 01/01/08 05/04/08
02548 05/05/08 08/31/08


=SUM((-(BegDateTestD1)-(FinDateTest<=C1)+1)*(AttyIDTest=A2)*NETWORKDAYS(M AX(C1,BegDateTest),MIN(D1,FinDateTest)))

"Erin Searfoss" wrote:

Can anyone tell what I'm doing wrong here? If (on another sheet) IDTest =
$A$2:$A2, BegDateTest = $B$2:$B$2, and FinDateTest = $C$2:$C$2 the following
formula evaluates to 23. If IDTest = $A$3:$A3, BegDateTest = $B$3:$B$3, and
FinDateTest = $C$3:$C$3 the formula evaluates to 0. However, if IDTest =
$A$2:$A3, BegDateTest = $B$2:$B$3, and FinDateTest = $C$2:$C$3 the formula
evaluates to -68. I would expect 0 + 23. Anyone know why it isn't
evaluating to 23?

=SUM(IF((BegDateTestD1)+(FinDateTest<=C1)0,0,(ID Test=A2)*NETWORKDAYS(MAX(C1,BegDateTest),MIN(D1,Fi nDateTest))))

Any suggestions would be appreciated. Thanks.

Erin

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Array Formula

Nevermind. I figured out that the Max and Min were not working the way I was
thinking and the Networkdays doesn't work with array formulas at all.
Instead I wrote a custom function (see below). I try to avoid custom
function so If anyone has an excel formula to calculate work days in an array
formula please let me know. Thanks.

Function WorkDays(BegDates, EndDates, AttyID, BegPer, EndPer, ID, Holidays)
As Single

Dim FirstDate As Date
Dim LastDate As Date
Dim TestDate As Date
Dim SumDays As Single

WorkDays = 0

If TypeName(BegDates) < "Range" Or TypeName(EndDates) _
< "Range" Or TypeName(AttyID) < "Range" Or TypeName(Holidays) <
"Range" Then GoTo ErrRtn
If BegDates.Cells.Count < EndDates.Cells.Count Or EndDates.Cells.Count <
AttyID.Cells.Count _
Then GoTo ErrRtn

For i = 0 To BegDates.Cells.Count
If Not (BegDates(i) EndPer Or EndDates(i) < EndPer) Then
If AttyID(i) = ID Then
FirstDate = Application.WorksheetFunction.Max(BegPer, BegDates(i))
LastDate = Application.WorksheetFunction.Min(EndPer, EndDates(i))
SumDays = 0
TestDate = FirstDate
Do While TestDate <= LastDate
If Weekday(TestDate) < 1 And Weekday(TestDate) < 7 Then
SumDays = SumDays + 1
For j = 0 To Holidays.Cells.Count
If TestDate = Holidays(j) Then SumDays = SumDays
- 1
Next j
End If
TestDate = TestDate + 1
Loop
WorkDays = WorkDays + SumDays
End If
End If
Next i

Exit Function

ErrRtn:
WorkDays = CVErr(xlErrValue)

End Function

"Erin Searfoss" wrote:

I tried getting rid of the IF as well with the same result. The values in
A2, C1 and D1 are 02548, 12/31/07 and 1/31/08, repectively while the second
sheet looks like this.

ID Beg Date Fin Date
02548 01/01/08 05/04/08
02548 05/05/08 08/31/08


=SUM((-(BegDateTestD1)-(FinDateTest<=C1)+1)*(AttyIDTest=A2)*NETWORKDAYS(M AX(C1,BegDateTest),MIN(D1,FinDateTest)))

"Erin Searfoss" wrote:

Can anyone tell what I'm doing wrong here? If (on another sheet) IDTest =
$A$2:$A2, BegDateTest = $B$2:$B$2, and FinDateTest = $C$2:$C$2 the following
formula evaluates to 23. If IDTest = $A$3:$A3, BegDateTest = $B$3:$B$3, and
FinDateTest = $C$3:$C$3 the formula evaluates to 0. However, if IDTest =
$A$2:$A3, BegDateTest = $B$2:$B$3, and FinDateTest = $C$2:$C$3 the formula
evaluates to -68. I would expect 0 + 23. Anyone know why it isn't
evaluating to 23?

=SUM(IF((BegDateTestD1)+(FinDateTest<=C1)0,0,(ID Test=A2)*NETWORKDAYS(MAX(C1,BegDateTest),MIN(D1,Fi nDateTest))))

Any suggestions would be appreciated. Thanks.

Erin

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
array formula RN Mark Excel Worksheet Functions 2 August 27th 08 05:50 PM
Help with Array formula? Victor Delta[_2_] Excel Discussion (Misc queries) 4 August 9th 08 03:12 AM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Need Help With Array Formula rmeister Excel Discussion (Misc queries) 4 January 6th 06 03:06 PM
Array Formula - using LEFT("text",4) in formula Andrew L via OfficeKB.com Excel Worksheet Functions 2 August 1st 05 02:36 PM


All times are GMT +1. The time now is 10:40 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"