AW: Problem bei Eingabemaske
24.03.2014 12:55:49
Dauergast
Hallo,
zunächst einmal danke für die Antworten...Ich habe meinen Code jetzt verändert, doch funktioniert er leider immer noch nicht. Könnt Ihr mir sagen wo der Fehler liegt? Muss ich im Modul 3 meinen Code auch ändern?!
Option Explicit
Option Compare Text
Private Sub CommandButton1_Click()
Dim lZeile As Long
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) ""
lZeile = lZeile + 1
Loop
Tabelle1.Cells(lZeile, 1) = CStr("Neuer Eintrag Zeile " & lZeile)
ListBox1.AddItem CStr("Neuer Eintrag Zeile " & lZeile)
ListBox1.ListIndex = ListBox1.ListCount - 1
End Sub
Private Sub CommandButton2_Click()
Dim lZeile As Long
If ListBox1.ListIndex = -1 Then Exit Sub
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) ""
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
Tabelle1.Rows(CStr(lZeile & ":" & lZeile)).Delete
Call UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
Exit Do
End If
lZeile = lZeile + 1
Loop
End Sub
Private Sub CommandButton3_Click()
Dim lZeile As Long
If ListBox1.ListIndex = -1 Then Exit Sub
If Trim(CStr(TextBox1.Text)) = "" Then
Exit Sub
End If
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) ""
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
Tabelle1.Cells(lZeile, 1).Value = Trim(CStr(TextBox1.Text))
Tabelle1.Cells(lZeile, 31).Value = TextBox2.Text
Tabelle1.Cells(lZeile, 32).Value = TextBox3.Text
Tabelle1.Cells(lZeile, 33).Value = TextBox4.Text
Tabelle1.Cells(lZeile, 34).Value = TextBox5.Text
Tabelle1.Cells(lZeile, 35).Value = TextBox6.Text
Tabelle1.Cells(lZeile, 36).Value = TextBox7.Text
If ListBox1.Text Trim(CStr(TextBox1.Text)) Then
Call UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
End If
Exit Do
End If
lZeile = lZeile + 1
Loop
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub
Private Sub ListBox1_Click()
Dim lZeile As Long
TextBox1 = ""
TextBox2 = Format(Date, "DD.MM.YYYY")
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
If ListBox1.ListIndex >= 0 Then
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) ""
If ListBox1.Text = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) Then
TextBox1 = Trim(CStr(Tabelle1.Cells(lZeile, 1).Value))
TextBox2 = Tabelle1.Cells(lZeile, 31).Value
TextBox3 = Tabelle1.Cells(lZeile, 32).Value
TextBox4 = Tabelle1.Cells(lZeile, 33).Value
TextBox5 = Tabelle1.Cells(lZeile, 34).Value
TextBox6 = Tabelle1.Cells(lZeile, 35).Value
TextBox7 = Tabelle1.Cells(lZeile, 36).Value
Exit Do
End If
lZeile = lZeile + 1
Loop
End If
End Sub
Private Sub UserForm_Activate()
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
End Sub
Private Sub UserForm_Initialize()
Dim lZeile As Long
TextBox1 = ""
TextBox2 = Format(Date, "DD.MM.YYYY")
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
lZeile = 2
Do While Trim(CStr(Tabelle1.Cells(lZeile, 1).Value)) ""
ListBox1.AddItem Trim(CStr(Tabelle1.Cells(lZeile, 1).Value))
lZeile = lZeile + 1
Loop
End Sub