AW: Kalenderwoche und Jahr aus Datum
17.07.2009 23:46:07
Josef
Hallo Gerhard,
' **********************************************************************
' Modul: Tabelle1 Typ: Element der Mappe(Sheet, Workbook, ...)
' **********************************************************************
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Column = 1 And .Row > 5 And .Count = 1 Then
'B als Text Formatieren, weil sonst manche Einträge als Datum interpretiert werden!
.Offset(0, 1).NumberFormat = "@"
.Offset(0, 1) = Format(DINKwoche(Target), "00") & Format(Target, "\/yy")
End If
End With
End Sub
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Public Function DINKwoche(ByVal Datum As Date) As Integer
Dim tmp As Date
tmp = DateSerial(Year(Datum + (8 - Weekday(Datum)) Mod 7 - 3), 1, 1)
DINKwoche = ((Datum - tmp - 3 + (Weekday(tmp) + 1) Mod 7)) \ 7 + 1
End Function
Gruß Sepp