AW: Mehrfache Einträge vermeiden ...
27.09.2013 08:41:41
Christian
Hallo Matthias
Danke für deine großartige Unterstützung. Ich habe den Code auf meine Bezeichnungen angebaste
Ich habe den kompltten Code für den Button Einfügen hier gepostet. Obwohl ich ein vorhandenen Wert eintrage kommt keine Meldung und es wird trotztdem dieser Wert eingetragen
Private Sub CommandButton_Einfügen_Click()
Dim WS As Worksheet
Dim Loletzte As Long
If MultiPage1.Value = 0 Then
Set WS = Worksheets("MyPortal")
Else
Set WS = Worksheets("OneERP")
End If
With WS
Loletzte = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
.Cells(Loletzte, 2) = TextBox_MyPortal_ID.Value
.Cells(Loletzte, 3) = TextBox_MyPortal_Bezeichnung.Value
.Cells(Loletzte, 4) = TextBox_S1_MyPortal.Value
.Cells(Loletzte, 5) = TextBox_S2_Myportal.Value
.Cells(Loletzte, 6) = TextBox_S3_Myportal.Value
.Cells(Loletzte, 7) = TextBox_S4_MyPortal.Value
.Cells(Loletzte, 8) = TextBox_S5_MyPortal.Value
.Cells(Loletzte, 9) = TextBox_S6_MyPortal.Value
If Me.MultiPage1.Value 0 Then
.Cells(Loletzte, 2) = TextBox_OneERP_ID.Value
.Cells(Loletzte, 3) = TextBox_OneERP_Bezeichnung.Value
.Cells(Loletzte, 4) = TextBox_S1_OneERP.Value
.Cells(Loletzte, 5) = TextBox_S2_OneERP.Value
.Cells(Loletzte, 6) = TextBox_S3_OneERP.Value
.Cells(Loletzte, 7) = TextBox_S4_OneERP.Value
.Cells(Loletzte, 8) = TextBox_S5_OneERP.Value
.Cells(Loletzte, 9) = TextBox_S6_OneERP.Value
End If
End With
Me.TextBox_MyPortal_ID = ""
Me.TextBox_MyPortal_Bezeichnung = ""
Me.TextBox_S1_MyPortal = ""
Me.TextBox_S2_Myportal = ""
Me.TextBox_S3_Myportal = ""
Me.TextBox_S4_MyPortal = ""
Me.TextBox_S5_MyPortal = ""
Me.TextBox_S6_MyPortal = ""
Me.TextBox_OneERP_ID = ""
Me.TextBox_OneERP_Bezeichnung = ""
Me.TextBox_S1_OneERP = ""
Me.TextBox_S2_OneERP = ""
Me.TextBox_S3_OneERP = ""
Me.TextBox_S4_OneERP = ""
Me.TextBox_S5_OneERP = ""
Me.TextBox_S6_OneERP = ""
Dim TbTxt As String, RnG As Range, MyBool As Boolean, MyRow&
If TextBox_MyPortal_ID.Value "" Then
MyBool = True
MyRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
TbTxt = TextBox_MyPortal_ID.text
For Each RnG In Range("B3:B" & MyRow)
If TbTxt = RnG.Value Then
MsgBox "Wert aus TextBox_MyPortal_ID" & vbLf & TbTxt & vbLf & " ist schon vorhanden "
MyBool = False
End If
Next
If MyBool Then Range("B" & MyRow) = TbTxt
End If
End Sub