AW: Userform - Gültigkeit der Eingabe abfragen
29.08.2006 11:33:48
Rupert
Ok der code, schon mit deinem find eingebaut
Private Sub CommandButton1_Click()
Dim letzteZeile As Long
Dim z As Range
Set z = Sheets("Artikel_Stammdaten").Range("B:B").Find(What:=TextBox1, LookAt:=xlWhole)
If z Is Nothing Then
MsgBox "Wrong Articlenumber inputed try again"
End If
With ThisWorkbook.Sheets("DATENBANK")
letzteZeile = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
If ComboBox1.Value = "NEW-1" Then
.Unprotect
.Cells(letzteZeile, 1) = TextBox1.Value
.Cells(letzteZeile, 3) = ComboBox1.Value
.Cells(letzteZeile, 4) = Format(TextBox3, ">")
.Cells(letzteZeile, 5) = TextBox4.Value
.Cells(letzteZeile, 6) = TextBox5.Value
Range("B2").AutoFill Destination:=Range("B2:B" & Cells(Rows.Count, 1).End(xlUp).Row)
Range("G2").AutoFill Destination:=Range("G2:G" & Cells(Rows.Count, 1).End(xlUp).Row)
.Protect
ActiveWorkbook.RefreshAll
TextBox1 = " "
TextBox3 = " "
TextBox5 = " "
ComboBox1.ListIndex = -1
TextBox6 = " "
ComboBox2.ListIndex = -1
Else
.Unprotect
.Cells(letzteZeile, 1) = TextBox1.Value
.Cells(letzteZeile, 3) = ComboBox2.Value
.Cells(letzteZeile, 4) = Format(TextBox6, ">")
.Cells(letzteZeile, 5) = TextBox4.Value
.Cells(letzteZeile, 6) = TextBox5.Value
Range("B2").AutoFill Destination:=Range("B2:B" & Cells(Rows.Count, 1).End(xlUp).Row)
Range("G2").AutoFill Destination:=Range("G2:G" & Cells(Rows.Count, 1).End(xlUp).Row)
.Protect
ActiveWorkbook.RefreshAll
End If
End With
TextBox1 = " "
TextBox3 = " "
TextBox5 = " "
ComboBox1.ListIndex = -1
TextBox6 = " "
ComboBox2.ListIndex = -1
End Sub
wie gesagt, das problem ist wenn jetzt die artikelnummer nicht stimmt, zeigt er mir die Msg-Box, jedoch beim blicken auf ok, übergibt er die daten an das Excelsheet.
Eine Feinheit wäre noch, wenn in der combobox 1 das new-1 steht das dann combobox 2 und textbox6 gesperrt werden für die eingabe, ist dann aber nur mehr feinheit.
ich werde aber weiterversuchen, vielleicht wenn du zeit hast, kannst du dir das bitte ansehen.
danke
rupert