Private Sub Worksheet_Change(ByVal Target As Range)
Dim Bereich As Range
Set Bereich = Intersect(Range("B12,E12,H12,B15,E15,H15,B18,E18,H18,B21,E21,H21"), Target)
If Not Bereich Is Nothing Then
Application.EnableEvents = False
For Each Bereich In Bereich.Areas
If Bereich.Offset(-2, 0) = "" Or Bereich.Offset(-1, 0) = "" Then
Bereich.Value = ""
End If
Next Bereich
Application.EnableEvents = True
End If
End Sub
Gruß TinoPrivate Sub Worksheet_Change(ByVal Target As Range)
Dim BereichRot As Range, BereichGelb As Range
Set BereichRot = Intersect(Range("B12,E12,H12,B15,E15,H15,B18,E18,H18,B21,E21,H21"), Target)
Set BereichGelb = Intersect(Range("B10:B11,E10:E11,H10:H11,H13:H14,E13:E14,B13:B14,B16:B17,E16:E17,H16:H17,H19:H20,E19:E20,B19:B20"), Target)
If Not BereichGelb Is Nothing Or Not BereichRot Is Nothing Then
Application.EnableEvents = False
If Not BereichGelb Is Nothing Then
For Each BereichGelb In BereichGelb.Areas
If BereichGelb(1, 1).Offset(2, 1).Value <> "" Then
If BereichGelb(1, 1) = "" Or BereichGelb(2, 1) = "" Then
BereichGelb(1, 1).Offset(2, 1).Value = ""
End If
End If
Next BereichGelb
End If
If Not BereichRot Is Nothing Then
For Each BereichRot In BereichRot.Areas
If BereichRot <> "" Then
If BereichRot.Offset(-2, 0) = "" Or BereichRot.Offset(-1, 0) = "" Then
BereichRot.Value = ""
If BereichRot.Offset(-1, 0) = "" Then
BereichRot.Offset(-1, 0).Select
ElseIf BereichRot.Offset(-2, 0) = "" Then
BereichRot.Offset(-2, 0).Select
End If
End If
End If
Next BereichRot
End If
Application.EnableEvents = True
End If
End Sub
Gruß TinoPrivate Sub Worksheet_Change(ByVal Target As Range)
Dim BereichRot As Range, BereichGelb As Range
Set BereichRot = Intersect(Range("B12,E12,H12,B15,E15,H15,B18,E18,H18,B21,E21,H21"), Target)
Set BereichGelb = Intersect(Range("B10:B11,E10:E11,H10:H11,H13:H14,E13:E14,B13:B14,B16:B17,E16:E17,H16:H17,H19:H20,E19:E20,B19:B20"), Target)
If Not BereichGelb Is Nothing Or Not BereichRot Is Nothing Then
Application.EnableEvents = False
If Not BereichGelb Is Nothing Then
For Each BereichGelb In BereichGelb.Areas
If BereichGelb(1, 1).Offset(2, 0).Value <> "" Then
If BereichGelb(1, 1) = "" Or BereichGelb(2, 1) = "" Then
BereichGelb(1, 1).Offset(2, 0).Value = ""
End If
End If
Next BereichGelb
End If
If Not BereichRot Is Nothing Then
For Each BereichRot In BereichRot.Areas
If BereichRot <> "" Then
If BereichRot.Offset(-2, 0) = "" Or BereichRot.Offset(-1, 0) = "" Then
BereichRot.Value = ""
If BereichRot.Offset(-1, 0) = "" Then
BereichRot.Offset(-1, 0).Select
ElseIf BereichRot.Offset(-2, 0) = "" Then
BereichRot.Offset(-2, 0).Select
End If
End If
End If
Next BereichRot
End If
Application.EnableEvents = True
End If
End Sub
Gruß TinoIf BereichGelb(1, 1).Offset(2, 0).Value <> "" Then
und die dazugehörige End IF.'...
If Not BereichGelb Is Nothing Then
For Each BereichGelb In BereichGelb.Areas
If BereichGelb(1, 1) = "" Or BereichGelb(2, 1) = "" Then
BereichGelb(1, 1).Offset(2, 0).Value = ""
End If
Next BereichGelb
End If
'...
Gruß Tino