Ich habe im Netz viele Hinweise gefunden, kann diese aber nicht umsetzen.
Mit folgendem Code trage ich per Commandbutton die Werte aus Combo- und Textboxen in ein Tabellenblatt.
Vor der Eintragung wird geprüft ob alle Pflichtboxen gefüllt sind bzw. 2 Textboxen den gleichen Wert haben.
Eine Kontrollabfrage fehlt mir noch, die ich nicht hinbekomme:
In der TextBoxB_ER muss in 99% aller Fälle ein Minusbetrag stehen. Deshalb möchte ich dort eine Sicherheitsabfrage einbauen.
Ist der Wert der TextboxB_ER positiv (null habe ich ja schon abgefragt) soll eine Ja Nein Msg erscheinen. Bei Ja sollen die Eintragungen vorgenommen werden. Bei nein sollen die Textboxen B_ER und 1 - 32 wieder auf 0,00 gestellt werden und der Fokus auf TextBoxleerER gesetzt werden.
Private Sub CommandButtonER_Click()
Dim lngZeile As Long
lngZeile = Cells(5, 1).End(xlDown).Row + 1
' Abfrage ob Pflichtfelder gefüllt sind
If ComboBox_BuchungsortER.ListIndex = -1 Or ComboBox_BuchungsdatumER.ListIndex = -1 Or _
TextBoxB_ER.Value = 0 Or ComboBox_DatenER.Text = "" Or ComboBox_VorgangER.Text = "" Then
MsgBox "Bitte alle Pflichtfelder * füllen!", vbInformation, "Achtung"
TextBoxleerER.SetFocus
Else
' Abfrage ob Buchungswert ungleich Summenwert
If CDbl(TextBoxB_ER.Value) CDbl(TextBoxSummeER.Value) Then
MsgBox "Der Rechnungsbetrag stimmt nicht mit der Summe der Kontobuchnungen überein!", _
vbInformation, "Achtung"
TextBoxleerER.SetFocus
Else
Cells(lngZeile, 1).Value = ComboBox_BuchungsdatumER.Value
Cells(lngZeile, 6).Value = TextBoxB_ER.Value * 1
Cells(lngZeile, 3).Value = ComboBox_DatenER.Value
Cells(lngZeile, 4).Value = ComboBox_VorgangER.Value
Cells(lngZeile, 7).Value = TextBox1.Value * 1
Cells(lngZeile, 8).Value = TextBox2.Value * 1
Cells(lngZeile, 9).Value = TextBox3.Value * 1
Cells(lngZeile, 10).Value = TextBox4.Value * 1
Cells(lngZeile, 11).Value = TextBox5.Value * 1
Cells(lngZeile, 12).Value = TextBox6.Value * 1
Cells(lngZeile, 13).Value = TextBox7.Value * 1
Cells(lngZeile, 14).Value = TextBox8.Value * 1
Cells(lngZeile, 15).Value = TextBox9.Value * 1
Cells(lngZeile, 16).Value = TextBox10.Value * 1
Cells(lngZeile, 17).Value = TextBox11.Value * 1
Cells(lngZeile, 18).Value = TextBox12.Value * 1
Cells(lngZeile, 19).Value = TextBox13.Value * 1
Cells(lngZeile, 20).Value = TextBox14.Value * 1
Cells(lngZeile, 21).Value = TextBox15.Value * 1
Cells(lngZeile, 22).Value = TextBox16.Value * 1
Cells(lngZeile, 23).Value = TextBox17.Value * 1
Cells(lngZeile, 24).Value = TextBox18.Value * 1
Cells(lngZeile, 25).Value = TextBox19.Value * 1
Cells(lngZeile, 26).Value = TextBox20.Value * 1
Cells(lngZeile, 27).Value = TextBox21.Value * 1
Cells(lngZeile, 28).Value = TextBox22.Value * 1
Cells(lngZeile, 29).Value = TextBox23.Value * 1
Cells(lngZeile, 30).Value = TextBox24.Value * 1
Cells(lngZeile, 31).Value = TextBox25.Value * 1
Cells(lngZeile, 32).Value = TextBox26.Value * 1
Cells(lngZeile, 33).Value = TextBox27.Value * 1
Cells(lngZeile, 34).Value = TextBox28.Value * 1
Cells(lngZeile, 35).Value = TextBox29.Value * 1
Cells(lngZeile, 36).Value = TextBox30.Value * 1
Cells(lngZeile, 37).Value = TextBox31.Value * 1
Cells(lngZeile, 38).Value = TextBox32.Value * 1
End If
End If
End Sub
Kann mir bitte Jemand weiterhelfen.Vielen Dank fürs lesen und die Hilfe.
mfg, Andreas