View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 65
Default Function weirdness - #VALUE, then #NAME, then working fine??

On May 23, 7:17 am, Barb Reinhardt
wrote:
Can you show the function?


Barb:

I'm pretty rough in coding! I hope this doesn't give you nightmares!

The basic idea is to count the number of days (WorkdaysLater) from the
start date (OrderDate), counting only Monday through Thursday and not
holidays. Holidays are set and come up in strDates.

Ed

Public Function DueDate(OrderDate As Date, WorkdaysLater As Integer)
As Date
Dim iCt As Integer
Dim iCt2 As Integer
Dim x As Integer
Dim strDates As String
Dim strDay As String
'Stop
strDates = ActiveSheet.Range("IN14").Text
strDates = strDates & ActiveSheet.Range("IP14").Text

iCt = 0
iCt2 = 0
x = WorkdaysLater
If x 1 Then
Do
iCt = iCt + 1
If Weekday(OrderDate + iCt) 1 And _
Weekday(OrderDate + iCt) < 6 Then
strDay = OrderDate + iCt
If InStr(1, strDates, strDay, vbTextCompare) = 0 Then
iCt2 = iCt2 + 1
End If
End If
Loop Until iCt2 = x - 1
Else
Do
iCt = iCt + 1
If Weekday(OrderDate + iCt) 1 And _
Weekday(OrderDate + iCt) < 6 Then
strDay = OrderDate + iCt
If InStr(1, strDates, strDay, vbTextCompare) = 0 Then
iCt2 = iCt2 + 1
End If
End If
Loop Until iCt2 = x
End If
DueDate = Format(OrderDate + iCt, "mm/dd/yy")
End Function