Ich möchte in VBA das Datum von Montag und von Sonntag an hand der KW berechnen.
Wie muß ich das machen?
Gruß Thomas
Function DatInWoche(iJahr As Integer, iKW As Integer, iWT As Integer)
'=("4.1."&A2)+A1*7-7-REST("2.1."&A2;7)
DatInWoche = DateValue("4.1." & iJahr) + iKW * 7 - 8 - DateValue("2.1." & iJahr) Mod 7 + iWT
End Function
Public Function Kalenderwoche(Datum As Date)
Kalenderwoche = Format(Datum, "ww", 2, 2)
End Function
Aufruf:
MsgBox (Kalenderwoche(Date))
Gruß von LuschiPublic Function Kalenderwoche(Datum As Date)
Kalenderwoche = Format(Datum, "ww", vbMonday, vbFirstFourDays)
End Function
Sub test()
MsgBox Kalenderwoche(CVDate("31.12.2007"))
End Sub
ergibt bei mit WinXP & ExcelXP die Kalenderwoche 53.