Jeg har lavet tabellerne og klippet VBA koden ind i VBA module...
Men den kommer ikke ud med regnestykket.
Hvad skal jeg gøre i workdays feltet for at den kommer frem til dagenene...?
Fanger ikke helt det de skriver om Datdiff mv.
NB: Har klibbet disse to moduler ind:
Public Function Weekdays(ByRef startDate As Date, _ ByRef endDate As Date _ ) As Integer ' Returns the number of weekdays in the period from startDate ' to endDate inclusive. Returns -1 if an error occurs. ' If your weekend days do not include Saturday and Sunday and ' do not total two per week in number, this function will ' require modification. On Error GoTo Weekdays_Error
' The number of weekend days per week. Const ncNumberOfWeekendDays As Integer = 2
' The number of days inclusive. Dim varDays As Variant
' The number of weekend days. Dim varWeekendDays As Variant
' Temporary storage for datetime. Dim dtmX As Date
' If the end date is earlier, swap the dates. If endDate < startDate Then dtmX = startDate startDate = endDate endDate = dtmX End If
' Calculate the number of days inclusive (+ 1 is to add back startDate). varDays = DateDiff(Interval:="d", _ date1:=startDate, _ date2:=endDate) + 1
Public Function Workdays(ByRef startDate As Date, _ ByRef endDate As Date, _ Optional ByRef strHolidays As String = "Holidays" _ ) As Integer ' Returns the number of workdays between startDate ' and endDate inclusive. Workdays excludes weekends and ' holidays. Optionally, pass this function the name of a table ' or query as the third argument. If you don't the default ' is "Holidays". On Error GoTo Workdays_Error Dim nWeekdays As Integer Dim nHolidays As Integer Dim strWhere As String
' DateValue returns the date part only. startDate = DateValue(startDate) endDate = DateValue(endDate)
nWeekdays = Weekdays(startDate, endDate) If nWeekdays = -1 Then Workdays = -1 GoTo Workdays_Exit End If
Når det er VBA så har du mulighed for at compile/debugge (kan ikke lige huske hvor det er i menuen) så burde den have fanget den fejl.
Tak for point
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.