Gruppe
Ereignis
Bereich
Open
Thema
Geburtstagsmeldung bei Öffnen der Arbeitsmappe
Problem
Wie kann ich mir jedesmal beim Öffnen einer bestimmten Mappe anzeigen lassen, wer Geburtstag hat?
Lösung
Geben Sie den Ereigniscode in das Klassenmodul der Arbeitsmappe ein.
ClassModule: DieseArbeitsmappe
Private Sub Workbook_Open()
Dim dat As Date
Dim iRow As Integer
Dim sTxt As String
iRow = 2
Do Until IsEmpty(Cells(iRow, 1))
dat = Cells(iRow, 4).Value
If Month(dat) = Month(Date) And _
Day(dat) = Day(Date) Then
sTxt = sTxt & Cells(iRow, 2).Value & " " & _
Cells(iRow, 1).Value & " wird " & _
Cells(iRow, 3).Value & vbLf
End If
iRow = iRow + 1
Loop
If sTxt <> "" Then
MsgBox "Geburtstage:" & vbLf & sTxt
Else
MsgBox "Es liegt kein Geburtstag an!"
End If
End Sub