habe ein Problem:
In Textbox4 wird das aktuelle Datum eingetragen(bzw. die TB ist damit vorbelegt).
Jetzt kommts: Ich möchte den Zellwert der darüberliegenden Zelle vergleichen, ob
der Inhalt das Datum von einem anderen Jahr ist(Bsp 03). Wenn ja, soll wieder ab 1 gezählt werden.
Hier mal mein bisheriger Code:
'Eintragen der Werte
Private Sub CommandButton1_Click()
On Error Resume Next
ErsteFreieA
z = ActiveCell.Row
If Cells(8, 3) <> "" Then
Cells(z, 1).Value = TextBox1.Value
Cells(z, 2).Value = TextBox2.Value
Cells(z, 11).Value = TextBox3.Value
'Erhöhung der Werte über St.zahl in Textbox
Cells(z, 8).Value = Cells(z - 1, 8).Value + CDbl(TextBox2.Text)
'Berechnung des ersten Wertes in Spalte D
Cells(z, 4).Value = Cells(z - 1, 8).Value + 1
'bleibt immer gleich
Cells(z, 3).Value = Cells(z - 1, 3).Value 'für HR
Cells(z, 5).Value = Cells(z - 1, 5).Value 'für /
Cells(z, 6).Value = Format(Date, "yy")
Cells(z, 7).Value = Cells(z - 1, 7).Value 'für -
Cells(z, 9).Value = Cells(z - 1, 9).Value 'für /
Cells(z, 10).Value = Format(Date, "yy")
Else
Cells(8, 1).Value = TextBox1.Value
Cells(8, 2).Value = TextBox2.Value
Cells(8, 11).Value = TextBox3.Value
Cells(8, 3).Value = "HR"
Cells(8, 4).Value = "01"
Cells(8, 5).Value = "/"
Cells(8, 6).Value = Format(Date, "yy")
Cells(8, 7).Value = "-"
Cells(8, 8).Value = Cells(8, 8).Value + CDbl(TextBox2.Text)
Cells(8, 9).Value = "/"
Cells(8, 10).Value = Format(Date, "yy")
End If
'++++++++++ das läuft leider nicht... ++++++++++
'prüfen ob Jahr richtig --> wenn nicht dann wieder von 01 zählen
If TextBox4.Value <> Cells(z - 1, 6).Value Then
Cells(z, 3).Value = "HR"
Cells(z, 4).Value = "01"
Cells(z, 5).Value = "/"
Cells(z, 6).Value = Format(Date, "yy")
Cells(z, 7).Value = "-"
Cells(z, 8).Value = Cells(8, 8).Value + CDbl(TextBox2.Text)
Cells(z, 9).Value = "/"
Cells(z, 10).Value = Format(Date, "yy")
End If
End Sub
Vielleicht kann mir ja jemand helfen. Ein Tip wäre auch nicht schlecht.
Gruß Andi