Option Explicit
Dim intgeb As Integer
Dim Loletzte As Long
Dim MsgText As String
Dim intalter As Integer
Sub Geburtstag()
Loletzte = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
For intgeb = 2 To Loletzte
intalter = (DateSerial(Year(Date), Month(Date), Day(Date)) - DateSerial(Year(Cells(intgeb, 1)), Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1)))) / 365.25
If DateSerial(Year(Date), Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1))) >= DateSerial(Year(Date), Month(Date), Day(Date)) _
And DateSerial(Year(Date), Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1))) <= DateSerial(Year(Date), Month(Date), Day(Date) + 0) _
Or DateSerial(Year(Date) + 1, Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1))) <= DateSerial(Year(Date), Month(Date), Day(Date) + 0) Then
MsgText = MsgText & vbLf & vbLf & Cells(intgeb, 1 + 2) & " " & Cells(intgeb, 1 + 1) & " " & "wird " & intalter & " Jahre alt"
ElseIf DateSerial(Year(Date), Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1))) + 1 >= DateSerial(Year(Date), Month(Date), Day(Date)) _
And DateSerial(Year(Date), Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1))) <= DateSerial(Year(Date), Month(Date), Day(Date) + 0) _
Or DateSerial(Year(Date) + 1, Month(Cells(intgeb, 1)), Day(Cells(intgeb, 1))) <= DateSerial(Year(Date), Month(Date), Day(Date) + 0) Then
MsgText = MsgText & vbLf & vbLf & Cells(intgeb, 1 + 2) & " " & Cells(intgeb, 1 + 1) & " " & "ist gestern " & intalter & " Jahre alt geworden"
End If
Next intgeb
If Len(MsgText) > 0 Then
MsgBox Right(MsgText, Len(MsgText) - 2), , "Geburtstag haben heute"
Else
MsgBox "heute hat keiner Geburtstag", , "Geburtstag"
End If
End Sub
Handbuch zur Einführung in die VBA Programmierung in EXCEL
pvp 29.04.2007 - 357 Hits - 2 Antworten
VBA Skript für Farbumstellung an Powerpointfolien
IDone 11.01.2008 - 28 Hits -
mehre Excel Arbeitsblaetter in PowerPoint via VBA ansprechen
sammille 12.03.2008 - 100 Hits -