AW: Wieder Problem mit Eingabemaske
28.03.2014 10:19:17
Rudi
Hallo,
Code komplett überarbeitet:
Option Explicit
Option Compare Text
Private Sub CommandButton1_Click()
Dim lZeile As Long
lZeile = Tabelle1.Cells(Rows.Count, 1).End(xlUp).Row + 1
Tabelle1.Cells(lZeile, 1) = CStr("Neuer Eintrag Zeile " & lZeile)
UserForm_Initialize
ListBox1.ListIndex = ListBox1.ListCount - 1
End Sub
Private Sub CommandButton2_Click()
If ListBox1.ListIndex = -1 Then Exit Sub
Tabelle1.Rows(ListBox1.Column(1)).Delete
UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = 0
End Sub
Private Sub CommandButton3_Click()
Dim lZeile As Long, lIndex As Long
If ListBox1.ListIndex = -1 Then Exit Sub
lIndex = ListBox1.ListIndex
If Trim(TextBox1.Text) = "" Then
Exit Sub
End If
lZeile = ListBox1.Column(1)
With Tabelle1
.Cells(lZeile, 1).Value = Trim(TextBox1.Text)
.Cells(lZeile, 37).Value = TextBox2.Text
.Cells(lZeile, 38).Value = TextBox3.Text
.Cells(lZeile, 39).Value = TextBox4.Text
.Cells(lZeile, 40).Value = TextBox5.Text
.Cells(lZeile, 41).Value = TextBox6.Text
.Cells(lZeile, 42).Value = TextBox7.Text
End With
UserForm_Initialize
If ListBox1.ListCount > 0 Then ListBox1.ListIndex = lIndex
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 > -1 Then
lZeile = ListBox1.Column(1)
With Tabelle1
TextBox1 = Trim(.Cells(lZeile, 1).Value)
TextBox3 = .Cells(lZeile, 38).Value
TextBox4 = .Cells(lZeile, 39).Value
TextBox5 = .Cells(lZeile, 40).Value
TextBox6 = .Cells(lZeile, 41).Value
TextBox7 = .Cells(lZeile, 42).Value
End With
End If
End Sub
Private Sub UserForm_Initialize()
Dim lZeile As Long, arrList
TextBox1 = ""
TextBox2 = Format(Date, "DD.MM.YYYY")
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
With Tabelle1
arrList = .Range(.Cells(2, 1), .Cells(Rows.Count, 1).End(xlUp)).Resize(, 2)
End With
For lZeile = 1 To UBound(arrList)
arrList(lZeile, 2) = lZeile + 1
Next
ListBox1.List = arrList
End Sub
Gruß
Rudi