Datumsprüfung über VBA
28.08.2003 10:54:36
Chiara
ich versuche gerade eine Indikatoranpassung an gültigkeitsdaten zu binden. in jeder spalte soll der gültige Indikator stehen. da manche Ind. nicht am 1. eines monats wechseln hab ich mit hilfe datepart M und Y herausgegriffen und verglichen. - es funktioniert leider nicht. weiß denn irgendwer wie ihr mir da weiter helfen könnt???
Function Indikator(Datum, Gültig_bis1, Gültig_bis2, Gültig_bis3, Anpassung1)
' Datumsprüfung, welcher Indikator angewendet werden muss
a = DatePart("m", Datum)
b = DatePart("yyyy", Datum)
c = DatePart("m", Anpassung1)
d = DatePart("yyyy", Anpassung1)
e = DatePart("m", Gültig_bis1)
f = DatePart("yyyy", Gültig_bis1)
g = DatePart("m", Gültig_bis2)
h = DatePart("yyyy", Gültig_bis2)
i = DatePart("m", Gültig_bis3)
j = DatePart("yyyy", Gültig_bis3)
If a < c And b < d Then Indikator = ""
If c = a And d = b Then Indikator = "Indikator1"
If d > b Then Indikator = "Indikator1"
If e = a And f = b Then Indikator = "Indikator2"
If f > b Then Indikator = "Indikator2"
If g = a And h = b Then Indikator = "Indikator3"
If h > b Then Indikator = "Indikator3"
If i >= a And j >= b Then Indikator = ""
End Function