AW: TextBox in UserForm durchblättern
24.06.2005 18:11:32
Hajo_Zi
Hallo Ducky,
1. vom Grundsatz sollte man unbedingt eine Variblen Defition durchführen (erste Zeile im Code Option Explicit)
2. Bei Einsatz der Tag eigenschaft könnte man bestimmt 50% des Codes einsparen.
Dim LoZeile As Long
Private Sub CommandButton5_Click()
' Vor
Dim LoLetzte As Long
LoLetzte = IIf(IsEmpty(Range("A65536")), Range("A65536").End(xlUp).Row, 65536)
If LoZeile < LoLetzte Then
LoZeile = LoZeile + 1
TextBox2.Value = Cells(LoZeile, 1)
TextBox3.Value = Cells(LoZeile, 2)
TextBox4.Value = Cells(LoZeile, 3)
TextBox5.Value = Cells(LoZeile, 4)
TextBox6.Value = Cells(LoZeile, 5)
TextBox7.Value = Cells(LoZeile, 6)
TextBox8.Value = Cells(LoZeile, 7)
TextBox9.Value = Cells(LoZeile, 8)
TextBox10.Value = Cells(LoZeile, 9)
TextBox12.Value = Cells(LoZeile, 11)
TextBox31.Value = Cells(LoZeile, 14)
TextBox15.Value = Cells(LoZeile, 15)
TextBox16.Value = Cells(LoZeile, 16)
TextBox17.Value = Cells(LoZeile, 17)
TextBox18.Value = Cells(LoZeile, 18)
TextBox19.Value = Cells(LoZeile, 19)
TextBox20.Value = Cells(LoZeile, 20)
TextBox21.Value = Cells(LoZeile, 21)
TextBox22.Value = Cells(LoZeile, 22)
TextBox30.Value = Cells(LoZeile, 23)
TextBox23.Value = Cells(LoZeile, 24)
TextBox24.Value = Cells(LoZeile, 25)
TextBox26.Value = Cells(LoZeile, 26)
TextBox27.Value = Cells(LoZeile, 27)
TextBox28.Value = Cells(LoZeile, 28)
TextBox32.Value = Cells(LoZeile, 29)
Else
MsgBox "kein Datensatz mehr vohanden"
End If
End Sub
Private Sub CommandButton6_Click()
'Programmierung der ZURÜCK-Taste
LoZeile = LoZeile - 1
If LoZeile <= 2 Then
MsgBox "kein Datensatz mehr vohanden"
Else
TextBox2.Value = Cells(LoZeile, 1)
TextBox3.Value = Cells(LoZeile, 2)
TextBox4.Value = Cells(LoZeile, 3)
TextBox5.Value = Cells(LoZeile, 4)
TextBox6.Value = Cells(LoZeile, 5)
TextBox7.Value = Cells(LoZeile, 6)
TextBox8.Value = Cells(LoZeile, 7)
TextBox9.Value = Cells(LoZeile, 8)
TextBox10.Value = Cells(LoZeile, 9)
TextBox12.Value = Cells(LoZeile, 11)
TextBox31.Value = Cells(LoZeile, 14)
TextBox15.Value = Cells(LoZeile, 15)
TextBox16.Value = Cells(LoZeile, 16)
TextBox17.Value = Cells(LoZeile, 17)
TextBox18.Value = Cells(LoZeile, 18)
TextBox19.Value = Cells(LoZeile, 19)
TextBox20.Value = Cells(LoZeile, 20)
TextBox21.Value = Cells(LoZeile, 21)
TextBox22.Value = Cells(LoZeile, 22)
TextBox30.Value = Cells(LoZeile, 23)
TextBox23.Value = Cells(LoZeile, 24)
TextBox24.Value = Cells(LoZeile, 25)
TextBox26.Value = Cells(LoZeile, 26)
TextBox27.Value = Cells(LoZeile, 27)
TextBox28.Value = Cells(LoZeile, 28)
TextBox32.Value = Cells(LoZeile, 29)
End If
End Sub
Private Sub UserForm_initialize()
'hier wird die Combo-Box mit den BS-Werten gefüllt
With ComboBox1
.AddItem "Januar "
.AddItem "Februar "
.AddItem "März "
.AddItem "April "
.AddItem "Mai "
.AddItem "Juni "
.AddItem "Juli "
.AddItem "August "
.AddItem "September "
.AddItem "Oktober "
.AddItem "November "
.AddItem "Dezember "
End With
LoZeile = 3
End Sub
Gruß Hajo
Das Forum lebt auch von den Rückmeldungen.