Nach dem Aufruf einer Userform werden die Datensätze des aktuellen Arbeitsblattes in die jeweiligen Textboxen eingelesen.
Wenn man jetzt einen Datensatz über die Userform ändern möchte, so muß man nach der Änderung in der jewiligen Textbox nachstehenden Makro starten und die Daten sollten in der gleichen Zeile aktualisiert werden.
Die Daten werden jedoch als neuer Datensatz in Zeile 3 gespeichert. Der richtige Datensatz bleibt unverändert.
Wo gehört hier bitte etwas geändert?
Danke
Josef
Private Sub CommandButton1_Click()
'hier wird meldung erzeugt ob daten geändert werden sollen
Dim mldg, stil, titel, grc
mldg = "Datensatz wirklich ändern ?"
stil = vbYesNo + vbCritical + vbDefaultButton2
titel = "Frage ?"
grc = MsgBox(mldg, stil, titel)
If grc = vbYes Then
Else
Exit Sub
End If
'daten werden zurückgeschrieben mit der änderung
Dim R&
If cboListe.ListIndex = -1 Then
R = Cells(Rows.Count, 1).End(xlUp).Row + 1
Else
R = cboListe.ListIndex + 3
End If
Cells(R, 2) = txtAuswahl.Text
Cells(R, 3) = txtAuswahl1.Text
Cells(R, 5) = TxtAuswahl4.Text
Cells(R, 7) = txtAuswahl8.Text
Cells(R, 28) = txtAuswahl10.Text
Cells(R, 4) = txtAuswahl11.Text
Cells(R, 1) = txtAuswahl12.Text
Cells(R, 15) = txtAuswahl14.Text
Cells(R, 10) = txtAuswahl16.Text
Cells(R, 11) = txtAuswahl18.Text
Cells(R, 6) = txtAuswahl38.Text
Cells(R, 22) = txtAuswahl39.Text
Cells(R, 8) = txtAuswahl45.Text
Cells(R, 14) = txtAuswahl55.Text
Cells(R, 29) = txtauswahl56.Text
Cells(R, 12) = txtAuswahl57.Text
Cells(R, 21) = txtAuswahl58.Text
Cells(R, 13) = TextBox1.Text
Cells(R, 17) = TextBox2.Text
Cells(R, 18) = TextBox3.Text
Cells(R, 19) = TextBox4.Text
Cells(R, 20) = TextBox5.Text
Cells(R, 24) = TextBox6.Text
Cells(R, 25) = TextBox7.Text
Cells(R, 26) = TextBox8.Text
Cells(R, 27) = TextBox9.Text
Cells(R, 31) = TextBox10.Text
Cells(R, 32) = TextBox11.Text
Cells(R, 33) = TextBox12.Text
Cells(R, 34) = TextBox13.Text
Cells(R, 9) = TextBox14.Text
Cells(R, 16) = TextBox15.Text
Cells(R, 23) = TextBox16.Text
Cells(R, 30) = TextBox17.Text
frmInTextBox1.Hide
Call UserForm_Initialize
End Sub