AW: Meldung bei identischen Einträgen in 2 Spalten
ChrisL
Hi Werner
Alt + F11, Doppelklick auf Tabelle, Code einfügen.
Tabellenaufbau und Spalten müssen identisch mit Beispiel sein.
Gruss
Chris
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Or Target.Column = 7 Then
Dim iZeile As Long
Dim ManschaftA As String, ManschaftB As String
Dim Spieltag As String
ManschaftA = Cells(Target.Row, 4)
ManschaftB = Cells(Target.Row, 7)
For iZeile = 1 To Cells(65536, Target.Column).End(xlUp).Row
If iZeile <> Target.Row Then
If Cells(iZeile, 4) = ManschaftA And Cells(iZeile, 7) = ManschaftB Then
Spieltag = Cells(iZeile, 4).End(xlUp)
MsgBox "Die " & Vor_oder_Rück(Spieltag) & "rundenbegegnung " & ManschaftA & " / " & ManschaftB & " fand bereits am " & Spieltag & " statt!", _
vbExclamation, "Warnung"
Target = ""
Exit Sub
End If
End If
Next iZeile
End If
End Sub
Function Vor_oder_Rück(Spieltag As String) As String
Dim Tag As Byte
Tag = Left(Spieltag, InStr(Spieltag, ".") - 1)
If Tag
Vor_oder_Rück = "Vor"
Else
Vor_oder_Rück = "Rück"
End If
End Function