über eine Userform "frmEingabe_neue_Zahlung" gebe ich bestimmte Werte in eine Tabelle ein.
Über eine andere Userform "frmZahlung_aendern", die genauso aufgebaut ist wie die zur Eingabe, möchte ich die Werte der markierte Zeile in den dafür bestimmten (wie in der Eingabe-Userform) Textfeldern und Comboboxen zurückgeben lassen, verändern können und wieder in die Zellen übertragen.
So kann ich dann, gegebenen Falls die Eintragungen jeder Zeile über eine Userform nachträglich ändern.
Problem ist, daß die Textfelder in der Userform keinen festen Zellen zugeordnet sind, sondern einige wenn dann Abfragen durchlaufen werden müssen. Für die Eingabe ist das alles geregelt. Wie ich das in "umgekehrter Richtung" machen soll weiß ich nicht. Im Makro "UserForm_Initialize()" habe ich einiges versucht, bekomme es aber nicht hin (zu komplex für meine VBA-Kenntnisse).
Kann mir jemand helfen?
Meine Datei:
Die Datei https://www.herber.de/bbs/user/42242.xls wurde aus Datenschutzgründen gelöscht
Mein Code:
Option Explicit
Private Sub cboArt_AfterUpdate()
OK_True
End Sub
Private Sub cboAusgang_Eingang_Gesellschaft_Konto_AfterUpdate()
OK_True
End Sub
Private Sub cboGesellschaft_Konto_AfterUpdate()
OK_True
End Sub
Private Sub cboGesellschaft_Konto_Change()
Select Case cboGesellschaft_Konto.Text
Case "AS/Allgemeines Lewa", "AW/Allgemeines Lewa", _
"AW/Allgemeines Euro", "AW/Treuhand Lewa", "AW/Treuhand Euro"
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.Enabled = False
txtBetrag_MwSt.BackColor = 14737632
Case Else
txtBetrag_MwSt.Enabled = True
txtBetrag_MwSt.BackColor = &H80000005
End Select
End Sub
Private Sub cmdAbbrechen_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim cell As Range
Dim a As Long
Dim lbMsg As Byte
SpeedUp (True)
ActiveSheet.Unprotect Password:="Peter"
If Not IsDate(txtDatum.Text) = True Then
lbMsg = MsgBox("Geben Sie ein gültiges Datum ein", vbExclamation, "falsche Eingabe") _
txtDatum.Text = ""
txtDatum.SetFocus
cmdOK.Enabled = False
Exit Sub
End If
If Not IsDate(txtfaellig_zum.Text) = True Then
lbMsg = MsgBox("Geben Sie ein gültiges Datum ein", vbExclamation, "falsche Eingabe") _
txtfaellig_zum.Text = ""
txtfaellig_zum.SetFocus
cmdOK.Enabled = False
Exit Sub
End If
If cboAusgang_Eingang_Gesellschaft_Konto.Text = "Ausgang" Then
If Val(txtBetrag_Gesellschaft_Konto.Text) > 0 Then
lbMsg = MsgBox("Geben Sie einen negativen Wert ein", vbExclamation, " _
falsche Eingabe")
txtBetrag_Gesellschaft_Konto.Text = ""
txtBetrag_Gesellschaft_Konto.SetFocus
cmdOK.Enabled = False
Exit Sub
End If
If Val(txtBetrag_MwSt.Text) 0 Then
lbMsg = MsgBox("Geben Sie einen negativen Wert oder 0 ein", vbExclamation, " _
falsche Eingabe")
txtBetrag_MwSt.Text = ""
txtBetrag_MwSt.SetFocus
cmdOK.Enabled = False
Exit Sub
End If
End If
Range("A:A").Find("", after:=[A7]).Activate
'ActiveCell.Offset(-1, 0).EntireRow.Copy Destination:=ActiveCell
ActiveCell.EntireRow.SpecialCells(xlCellTypeConstants).ClearContents
ActiveCell.Value = CDate(Me.txtDatum)
ActiveCell.Offset(0, 1).Value = CDate(Me.txtfaellig_zum)
ActiveCell.Offset(0, 2).Value = Me.cboArt
ActiveCell.Offset(0, 3).Value = Me.txtGegenseite
ActiveCell.Offset(0, 4).Value = Me.txtZahlungsgrund
If Me.cboGesellschaft_Konto = "DA/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 5).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 10).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 6).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 9).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 13).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 10).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 14).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 9).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Kontokorrent Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 17).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 10).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Kontokorrent Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 18).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 9).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Kontokorrent Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 21).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 10).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Kontokorrent Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 22).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 9).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Treuhand Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 25).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 10).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Treuhand Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 26).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 9).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Treuhand Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 29).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 10).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "DA/Treuhand Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 30).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 9).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "AS/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 33).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AS/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 34).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "LB/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 37).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 42).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LB/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 38).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 41).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LB/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 45).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 42).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LB/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 46).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 41).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LHB/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 49).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 54).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LHB/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 50).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 53).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LHB/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 57).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 54).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "LHB/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 58).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
ActiveCell.Offset(0, 53).Value = CDec(Me.txtBetrag_MwSt)
End If
If Me.cboGesellschaft_Konto = "AW/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 61).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Allgemeines Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 62).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 65).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Allgemeines Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 66).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Treuhand Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 69).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Treuhand Lewa" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 70).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Treuhand Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang" Then
ActiveCell.Offset(0, 73).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
If Me.cboGesellschaft_Konto = "AW/Treuhand Euro" And Me. _
cboAusgang_Eingang_Gesellschaft_Konto = "Eingang" Then
ActiveCell.Offset(0, 74).Value = CDec(Me.txtBetrag_Gesellschaft_Konto)
End If
Unload Me
Range("A7:CM2000").Sort Key1:=Range("A7"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns(1).Find(CDate(Me.txtDatum)).Select
ActiveSheet.Protect Password:="Peter"
SpeedUp (False)
End Sub
Private Sub txtBetrag_Gesellschaft_Konto_AfterUpdate()
OK_True
End Sub
Private Sub txtBetrag_MwSt_AfterUpdate()
OK_True
End Sub
Private Sub txtDatum_AfterUpdate()
OK_True
End Sub
Private Sub txtfaellig_zum_AfterUpdate()
OK_True
End Sub
Private Sub txtGegenseite_AfterUpdate()
OK_True
End Sub
Private Sub txtZahlungsgrund_AfterUpdate()
OK_True
End Sub
Private Sub UserForm_Initialize()
Me.txtDatum = ActiveCell.Columns(1)
Me.txtfaellig_zum = ActiveCell.Columns(2)
With Me.cboArt
.AddItem "-"
.AddItem "-a"
.AddItem "-/+"
.AddItem "+"
.AddItem "+/-"
.AddItem "+a"
End With
Me.cboArt = ActiveCell.Columns(3)
Me.txtGegenseite = ActiveCell.Columns(4)
Me.txtZahlungsgrund = ActiveCell.Columns(5)
With Me.cboGesellschaft_Konto
.AddItem "DA/Allgemeines Lewa"
.AddItem "DA/Allgemeines Euro"
.AddItem "DA/Kontokorrent Lewa"
.AddItem "DA/Kontokorrent Euro"
.AddItem "DA/Treuhand Lewa"
.AddItem "DA/Treuhand Euro"
.AddItem "AS/Allgemeines Lewa"
.AddItem "LB/Allgemeines Lewa"
.AddItem "LB/Allgemeines Euro"
.AddItem "LHB/Allgemeines Lewa"
.AddItem "LHB/Allgemeines Euro"
.AddItem "AW/Allgemeines Lewa"
.AddItem "AW/Allgemeines Euro"
.AddItem "AW/Treuhand Lewa"
.AddItem "AW/Treuhand Euro"
End With
Me.cboGesellschaft_Konto = "Test" 'ActiveCell.Find("*", after:=Columns(5))
With Me.cboAusgang_Eingang_Gesellschaft_Konto
.AddItem "Ausgang"
.AddItem "Eingang"
End With
Me.cboAusgang_Eingang_Gesellschaft_Konto = "Ausgang"
Me.txtBetrag_Gesellschaft_Konto = Empty
Me.txtBetrag_MwSt = Empty
End Sub
Danke im Voraus
Grüße aus Berlin