Option
Explicit
Option
Compare Text
Private
Sub
CommandButton1_Click()
Dim
lZeile
As
Long
lZeile = 3
Do
While
Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value)) <>
""
lZeile = lZeile + 1
Loop
Tabelle3.Cells(lZeile, 1) =
CStr
(
"Neuer Eintrag "
& lZeile)
ListBox1.AddItem
CStr
(
"Neuer Eintrag "
& lZeile)
ListBox1.ListIndex = ListBox1.ListCount - 1
End
Sub
Private
Sub
CommandButton2_Click()
Dim
lZeile
As
Long
If
ListBox1.ListIndex = -1
Then
Exit
Sub
lZeile = 3
Do
While
Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value)) <>
""
If
ListBox1.Text = Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value))
Then
Tabelle3.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
(ComboBox1.Text)) =
""
Then
MsgBox
"Sie müssen eine Ebene eingeben!"
, vbCritical + vbOKOnly,
"FEHLER!"
Exit
Sub
End
If
If
Trim(
CStr
(ComboBox2.Text)) =
""
Then
MsgBox
"Sie müssen den Namen des Bereiches eingeben!"
, vbCritical + vbOKOnly,
"FEHLER!"
Exit
Sub
End
If
lZeile = 3
Do
While
Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value)) <>
""
If
ListBox1.Text = Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value))
Then
Tabelle3.Cells(lZeile, 1).Value = Trim(
CStr
(ComboBox1.Text))
Tabelle3.Cells(lZeile, 2).Value = ComboBox2.Text
If
ListBox1.Text <> Trim(
CStr
(ComboBox1.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
ComboBox1 =
""
ComboBox2 =
""
If
ListBox1.ListIndex >= 0
Then
lZeile = 3
Do
While
Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value)) <>
""
If
ListBox1.Text = Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value))
Then
ComboBox1 = Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value))
ComboBox2 = Tabelle3.Cells(lZeile, 2).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()
With
Me
.ComboBox1
ComboBox1.Clear
.AddItem (
"1"
)
.AddItem (
"2"
)
.AddItem (
"3"
)
End
With
Dim
lZeile
As
Long
ComboBox1 =
""
ComboBox2 =
""
ListBox1.Clear
lZeile = 3
Do
While
Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value)) <>
""
ListBox1.AddItem Trim(
CStr
(Tabelle3.Cells(lZeile, 1).Value))
lZeile = lZeile + 1
Loop
End
Sub