Private
Sub
Button_Abbrechen_Click()
Unload
Me
End
Sub
Private
Sub
Button_ändern_Click()
Dim
lngZeile
As
Long
Dim
i
As
Integer
If
Me
.ListBox1.ListIndex >= 0
Then
lngZeile =
Me
.ListBox1.Column(7,
Me
.ListBox1.ListIndex)
For
i = 2
To
12
tbl_Artikel.Cells(lngZeile, i).Value =
Me
.Controls(
"TextBox"
& i).Value
Next
i
For
i = 1
To
6
Me
.ListBox1.Column(i,
Me
.ListBox1.ListIndex) =
Me
.Controls(
"TextBox"
& i + 1).Value
Next
i
Else
MsgBox
"Bitte markieren Sie einen Datensatz im Listenfeld!"
End
If
End
Sub
Private
Sub
Button_Leeren_Click()
Dim
obj
As
Object
For
Each
obj
In
Me
.Controls
If
TypeName(obj) =
"TextBox"
Then
obj.Value =
""
End
If
Next
obj
Me
.ListBox1.Clear
End
Sub
Private
Sub
Button_Suchen_Click()
Dim
lngZeile
As
Long
Dim
lngZeileMax
As
Long
Dim
i
As
Integer
Me
.ListBox1.Clear
With
tbl_Artikel
lngZeileMax = .Cells(.Rows.Count, 1).
End
(xlUp).Row
For
lngZeile = 3
To
lngZeileMax
If
InStr(.Cells(lngZeile, 1).Value,
Me
.TextBox1.Value) > 0
Then
Me
.ListBox1.AddItem .Cells(lngZeile, 1).Value
Me
.ListBox1.Column(1, i) = .Cells(lngZeile, 2).Value
Me
.ListBox1.Column(2, i) = .Cells(lngZeile, 3).Value
Me
.ListBox1.Column(3, i) = .Cells(lngZeile, 4).Value
Me
.ListBox1.Column(4, i) = .Cells(lngZeile, 5).Value
Me
.ListBox1.Column(5, i) = .Cells(lngZeile, 6).Value
Me
.ListBox1.Column(6, i) = .Cells(lngZeile, 7).Value
Me
.ListBox1.Column(7, i) = lngZeile
i = i + 1
End
If
Next
lngZeile
End
With
End
Sub
Private
Sub
ListBox1_Click()
Dim
lngZeile
As
Long
Dim
i
As
Integer
lngZeile =
Me
.ListBox1.Column(7,
Me
.ListBox1.ListIndex)
For
i = 1
To
12
Me
.Controls(
"TextBox"
& i).Value = tbl_Artikel.Cells(lngZeile, i).Value
Next
i
End
Sub
Private
Sub
UserForm_Initialize()
Dim
i
As
Integer
Dim
wks
As
Worksheet
Set
wks = ThisWorkbook.Worksheets(
"tbl_Artikel"
)
With
wks
Me
.Caption = .Range(
"A1"
).Value
For
i = 1
To
12
Me
.Controls(
"Label"
& i).Caption = .Cells(2, i).Value
Next
i
For
i = 1
To
12
Me
.Controls(
"Label"
& i + 12).Caption = .Cells(2, i).Value
Next
i
End
With
With
Me
.ListBox1
.ColumnCount = 6
.ColumnWidths =
"90;200;75;75;40;40"
End
With
Me
.TextBox1.SetFocus
End
Sub