ich bin zu blöd für diesen Code.
Ich übertrage so Daten aus einer Listbox in eine UserForm:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With UF_Aenderung
.txtKunde.Value = ListBox1.List(ListBox1.ListIndex, 2)
.txtArt_Nr.Value = ListBox1.List(ListBox1.ListIndex, 0)
.txtKunde_Nr.Value = ListBox1.List(ListBox1.ListIndex, 1)
.TextBox2.Value = ListBox1.List(ListBox1.ListIndex, 3)
.TextBox3.Value = ListBox1.List(ListBox1.ListIndex, 4)
.CB_Sorte.Value = ListBox1.List(ListBox1.ListIndex, 5)
.CB_Roestung.Value = ListBox1.List(ListBox1.ListIndex, 6)
.CB_Zustand.Value = ListBox1.List(ListBox1.ListIndex, 7)
.TextBox5.Value = ListBox1.List(ListBox1.ListIndex, 8)
.TextBox6.Value = ListBox1.List(ListBox1.ListIndex, 11)
.CB_MHD.Value = ListBox1.List(ListBox1.ListIndex, 12)
.TextBox8.Value = ListBox1.List(ListBox1.ListIndex, 16)
.TextBox9.Value = ListBox1.List(ListBox1.ListIndex, 17)
.CB_Maschine.Value = ListBox1.List(ListBox1.ListIndex, 46)
.TextBox22.Value = ListBox1.List(ListBox1.ListIndex, 42)
.TextBox23.Value = ListBox1.List(ListBox1.ListIndex, 39)
.TextBox24.Value = ListBox1.List(ListBox1.ListIndex, 40)
.TextBox25.Value = ListBox1.List(ListBox1.ListIndex, 41)
.TextBox10.Value = ListBox1.List(ListBox1.ListIndex, 13)
.TextBox11.Value = ListBox1.List(ListBox1.ListIndex, 14)
.TextBox12.Value = ListBox1.List(ListBox1.ListIndex, 15)
.CB_Verpackungsart.Value = ListBox1.List(ListBox1.ListIndex, 18)
.CB_Ventil.Value = ListBox1.List(ListBox1.ListIndex, 19)
.CB_Gas.Value = ListBox1.List(ListBox1.ListIndex, 20)
.TextBox15.Value = ListBox1.List(ListBox1.ListIndex, 22)
.CB_Folie.Value = ListBox1.List(ListBox1.ListIndex, 23)
.CB_Etikett.Value = ListBox1.List(ListBox1.ListIndex, 24)
.CB_Druck.Value = ListBox1.List(ListBox1.ListIndex, 25)
.CB_Stempel.Value = ListBox1.List(ListBox1.ListIndex, 32)
.CB_EAN.Value = ListBox1.List(ListBox1.ListIndex, 26)
.TextBox16.Value = ListBox1.List(ListBox1.ListIndex, 27)
.TextBox18.Value = ListBox1.List(ListBox1.ListIndex, 28)
.TextBox17.Value = ListBox1.List(ListBox1.ListIndex, 29)
.TextBox19.Value = ListBox1.List(ListBox1.ListIndex, 30)
.TextBox20.Value = ListBox1.List(ListBox1.ListIndex, 31)
.CB_Palette.Value = ListBox1.List(ListBox1.ListIndex, 38)
.TextBox21.Value = ListBox1.List(ListBox1.ListIndex, 33)
.CB_Lieferant.Value = ListBox1.List(ListBox1.ListIndex, 34)
.CB_LageGross.Value = ListBox1.List(ListBox1.ListIndex, 35)
.CB_LageKlein.Value = ListBox1.List(ListBox1.ListIndex, 36)
.CB_Schutz.Value = ListBox1.List(ListBox1.ListIndex, 37)
.Show
End With
End Sub
Uns so übertrage ich die Werte aus der UserForm dann in die Tabelle:
Private Sub CommandButton2_Click()
'Daten korrigieren
Dim lngZeile As Long
Dim lngFundZeile As Long
Dim WS As Worksheet
Set WS = Tabelle3
With WS
' Aus UF_ArtikelÄndern - Artikeldaten eintragen ***
.Cells(lngZeile, 3).Value = CText(Me.txtKunde.Value)
.Cells(lngZeile, 2).Value = CZahl(Me.txtKunde_Nr.Value)
.Cells(lngZeile, 1).Value = CZahl(Me.txtArt_Nr.Value)
.Cells(lngZeile, 4).Value = CZahl(Me.TextBox2.Value)
.Cells(lngZeile, 5).Value = CText(Me.TextBox3.Value)
.Cells(lngZeile, 6).Value = C_Zahl_Text(Me.CB_Sorte.Value)
.Cells(lngZeile, 7).Value = CText(Me.CB_Roestung.Value)
.Cells(lngZeile, 8).Value = CText(Me.CB_Zustand.Value)
.Cells(lngZeile, 9).Value = C_Zahl_Text(Me.TextBox5.Value)
.Cells(lngZeile, 12).Value = C_Zahl_Text(Me.TextBox6.Value)
.Cells(lngZeile, 13).Value = CText(Me.CB_MHD.Value)
.Cells(lngZeile, 17).Value = CZahl(Me.TextBox8.Value)
.Cells(lngZeile, 18).Value = CZahl(Me.TextBox9.Value)
.Cells(lngZeile, 47).Value = CText(Me.CB_Maschine.Value)
.Cells(lngZeile, 43).Value = CZahl(Me.TextBox22.Value)
.Cells(lngZeile, 40).Value = CText(Me.TextBox23.Value)
.Cells(lngZeile, 41).Value = CText(Me.TextBox24.Value)
.Cells(lngZeile, 42).Value = CText(Me.TextBox25.Value)
' Aus UF_ArtikelÄndern - Verpackung eintragen ***
.Cells(lngZeile, 14).Value = CZahl(Me.TextBox10.Value)
.Cells(lngZeile, 15).Value = CZahl(Me.TextBox11.Value)
.Cells(lngZeile, 16).Value = CZahl(Me.TextBox12.Value)
.Cells(lngZeile, 19).Value = CText(Me.CB_Verpackungsart.Value)
.Cells(lngZeile, 20).Value = CText(Me.CB_Ventil.Value)
.Cells(lngZeile, 21).Value = CText(Me.CB_Gas.Value)
.Cells(lngZeile, 23).Value = CZahl(Me.TextBox15.Value)
.Cells(lngZeile, 24).Value = CText(Me.CB_Folie.Value)
.Cells(lngZeile, 25).Value = CText(Me.CB_Etikett.Value)
.Cells(lngZeile, 26).Value = CText(Me.CB_Druck.Value)
.Cells(lngZeile, 33).Value = CText(Me.CB_Stempel.Value)
.Cells(lngZeile, 27).Value = CText(Me.CB_EAN.Value)
.Cells(lngZeile, 28).Value = CText(Me.TextBox16.Value)
.Cells(lngZeile, 29).Value = CZahl(Me.TextBox18.Value)
.Cells(lngZeile, 30).Value = CText(Me.TextBox17.Value)
.Cells(lngZeile, 31).Value = CZahl(Me.TextBox19.Value)
.Cells(lngZeile, 32).Value = CText(Me.TextBox20.Value)
.Cells(lngZeile, 39).Value = CText(Me.CB_Palette.Value)
.Cells(lngZeile, 34).Value = CZahl(Me.TextBox21.Value)
.Cells(lngZeile, 35).Value = CText(Me.CB_Lieferant.Value)
.Cells(lngZeile, 36).Value = CText(Me.CB_LageGross.Value)
.Cells(lngZeile, 37).Value = CText(Me.CB_LageKlein.Value)
.Cells(lngZeile, 38).Value = CText(Me.CB_Schutz.Value)
.Cells(lngZeile, 46) = Lbl_KartonEtikett
If Lbl_KartonEtikett "" Then _
.Cells(lngZeile, 46).Hyperlinks.Add Anchor:=.Cells(lngZeile, 46), Address:= _
Lbl_KartonEtikett, TextToDisplay:=Lbl_KartonEtikett.Caption
.Cells(lngZeile, 45) = Lbl_Palettenetikett
If Lbl_Palettenetikett "" Then _
.Cells(lngZeile, 45).Hyperlinks.Add Anchor:=.Cells(lngZeile, 45), Address:= _
Lbl_Palettenetikett, TextToDisplay:=Lbl_Palettenetikett.Caption
End With
' Artikelmerkmale nach Kunde und Art-Nr sortieren
With WS.Range("A1").CurrentRegion
If .Rows.Count > 1 Then
.Sort .Cells(1, 3), xlAscending, .Cells(1, 1), , xlAscending, Header:=True
End If
End With
' Speichern
ThisWorkbook.Save
MsgBox ("Der Datensatz wurde geändert")
Set WS = Nothing
End Sub
Die Übertragung der Daten in die UserForm funktioniert.
Wenn ich die Daten aus der UserForm in die Tabelle schreiben will kommt dieses:
Laufzeitfehler: 1004
Anwenungs- oder objektdefinierter Fehler
Diese Zeile wird gelb markiert:
.Cells(lngZeile, 3).Value = CText(Me.txtKunde.Value)
Vielen Dank für eure Hilfe.
https://www.herber.de/bbs/user/100192.xlsm