Først må du finde datoerne for ugen. Den første dag, mandag, kan findes med min funktion DateYearWeek:
' Returns the date of Monday for the ISO 8601 week of IsoYear and Week.
' Optionally, returns the date of any other weekday of that week.
'
' 2017-05-03. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function DateYearWeek( _
ByVal IsoWeek As Integer, _
Optional ByVal IsoYear As Integer, _
Optional ByVal DayOfWeek As VbDayOfWeek = VbDayOfWeek.vbMonday) _
As Date
Dim WeekDate As Date
Dim ResultDate As Date
If IsoYear = 0 Then
IsoYear = Year(Date)
End If
' Validate parameters.
If Not IsWeekday(DayOfWeek) Then
' Don't accept invalid values for DayOfWeek.
Err.Raise DtError.dtInvalidProcedureCallOrArgument
Exit Function
End If
If Not IsWeek(IsoWeek, IsoYear) Then
' A valid week number must be passed.
Err.Raise DtError.dtInvalidProcedureCallOrArgument
Exit Function
End If
WeekDate = DateAdd(IntervalSetting(dtWeek), IsoWeek - 1, DateFirstWeekYear(IsoYear))
ResultDate = DateThisWeekPrimo(WeekDate, DayOfWeek)
DateYearWeek = ResultDate
End Function
Fuld kode i modul DateFind.bas, som findes i mit bibliotek:
https://github.com/GustavBrock/VBA.DateHvis dagen for denne dato er mellem 9 og 16 inklusive, skal tekstboksene skjules.
Det kan du formentlig gøre under hændelsen VedFormattering eller VedUdskrivning ved at sætte en variabel, Visible:
Visible = True hvis de skal vises, False hvis ikke,
og så styre visning af tekstboksene:
Me!Sum19.Visible = Visible
Me!Sum20.Visible = Visible