Habe untenstehendes Makro womit ich aus einer Userform Daten ins Datenblatt Objekte kopiere.
Da ich hunderte von Daten damit kopiere kann ich so nicht feststellen ob eine ObjektNr schon vergeben ist.
Ausschlaggebend ist immer die Textbox 94 wo ich eine Objektnr (z.b. 50000) eintrage und diese dann in Spalte A des Datenblatts Objekte kopiert wird.
Meine Frage ist es nun möglich eine Abfrage einzubauen die im Datenblatt die Spalte A vor dem speichern nach unten hin absucht ob die eingegebene Objektnr(Textbox 94)schon existiert, dann Meldung Objekt Nr existiert schon, trotzdem speichern ja/Nein und die aktuelle dann z.b in 50000-1 50000-2 u.s.w automatisch abändert.
Wenn möglich kann mir jemand den Code einbauen?
Bedanke mich
Mfg
Jürgen
Private Sub CommandButton1_Click()
Dim inty As Integer
With ThisWorkbook.Worksheets("Objekte")
inty = 2
Do Until .Cells(inty, 1) = ""
inty = inty + 1
Loop
.Cells(inty, 1) = TextBox94
.Cells(inty, 2) = ComboBox1
.Cells(inty, 3) = TextBox1
.Cells(inty, 4) = TextBox2
.Cells(inty, 5) = TextBox3
.Cells(inty, 6) = TextBox4
.Cells(inty, 7) = TextBox5
.Cells(inty, 8) = TextBox6
.Cells(inty, 9) = TextBox7
.Cells(inty, 10) = TextBox8
.Cells(inty, 11) = TextBox15
.Cells(inty, 12) = TextBox14
.Cells(inty, 13) = ComboBox2
.Cells(inty, 14) = TextBox17
.Cells(inty, 15) = TextBox18
.Cells(inty, 16) = TextBox19
.Cells(inty, 17) = TextBox20
.Cells(inty, 18) = TextBox21
.Cells(inty, 19) = TextBox22
.Cells(inty, 20) = TextBox23
.Cells(inty, 21) = TextBox24
.Cells(inty, 22) = TextBox25
.Cells(inty, 23) = TextBox26
.Cells(inty, 24) = ComboBox26
.Cells(inty, 25) = TextBox95
End With
End Sub