Funktioniert soweit ganz gut ist jedoch für den User zu umständlich würde gerne eine Vereinfachung
das ich direkt wenn ich die Listbox anklicke, ein Fenster auf geht wo ich dann direkt denn Kommentar eingeben kann. Momentan ist es über eine Combobox gelöst. hoffe da kann mir jemand helfen. siehe Code
Hier der Link wie es aussieht: https://www.herber.de/bbs/user/50500.jpg
darunter der VBA Code
Option Explicit
Dim wks As Worksheet
Dim wkb1, wkb2 As Workbook
Dim XBlatt, wks2 As Worksheet
Dim xZeile As Long
Dim Suchart As String
Dim xOpt As Integer
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Suchart = xlWhole
Else
Suchart = xlPart
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
ComboBox1.Enabled = False
Else
ComboBox1.Enabled = True
End If
End Sub
Private Sub ComboBox2_Click()
If ComboBox2.ListIndex 0 Then
TextBox3 = Cells(ComboBox2.ListIndex + 1, 1)
TextBox4 = Cells(ComboBox2.ListIndex + 1, 2)
Else
TextBox3 = ""
TextBox4 = ""
End If
End Sub
Private Sub ComboBox1_Change()
End Sub
Private Sub ComboBox2_Change()
End Sub
Private Sub CommandButton1_Click()
Dim xSuche, xAdresse, xErste As String
Dim y As Boolean
Dim arr() As Variant
Dim rng As Range
Dim iCounter, iRowU As Integer
ListBox1.Clear
xSuche = TextBox1.Value
If xSuche = "" Then
MsgBox "Bitte erst einen Suchbegriff eingeben!", vbExclamation, "Achtung!"
Exit Sub
End If
If ComboBox1.Value = "" And CheckBox2.Value = False Then
MsgBox "Bitte geben Sie ein, wo der Begriff gesucht werden soll!", vbExclamation, "Achtung!" _
_
_
_
Exit Sub
End If
For iCounter = 1 To ThisWorkbook.Sheets.Count
If CheckBox2.Value = True Or Worksheets(iCounter).Name = ComboBox1.Value Then
Set rng = Worksheets(iCounter).Cells.Find _
(xSuche, lookat:=Suchart, LookIn:=xlValues)
If Not rng Is Nothing Then
With Worksheets(iCounter)
xErste = rng.Address(False, False)
y = True
Do Until xAdresse = xErste
ReDim Preserve arr(0 To 6, 0 To iRowU)
arr(0, iRowU) = .Name
arr(1, iRowU) = rng.Address(False, False)
arr(2, iRowU) = .Cells(rng.Row, 1)
arr(3, iRowU) = .Cells(rng.Row, 2)
arr(4, iRowU) = .Cells(rng.Row, 3)
arr(5, iRowU) = .Cells(rng.Row, 4)
arr(6, iRowU) = .Cells(rng.Row, 5)
iRowU = iRowU + 1
Set rng = .Cells.FindNext(after:=rng)
xAdresse = rng.Address(False, False)
Loop
xAdresse = ""
xErste = ""
End With
End If
End If
Next iCounter
If y = False Then
MsgBox "Der Suchbegriff wurde nicht gefunden!"
Else
ListBox1.Column = arr
End If
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CommandButton3_Click()
Dim iCounter, xCounter As Long
Set wkb1 = ThisWorkbook
Set wkb2 = Workbooks.Add(1)
Set wks2 = wkb2.Sheets(1)
wkb1.Activate
For iCounter = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(iCounter) And xOpt = 1 Or xOpt = 2 Then
Set XBlatt = Sheets(ListBox1.List(iCounter, 0))
xZeile = Range(ListBox1.List(iCounter, 1)).Row
xCounter = xCounter + 1
XBlatt.Rows(xZeile).Copy wks2.Rows(xCounter)
End If
Next iCounter
wks2.Activate
End Sub
Private Sub CommandButton4_Click()
Dim iCounter, xCounter As Long
Set wkb1 = ThisWorkbook
Set wkb2 = Workbooks.Add(1)
Set wks2 = wkb2.Sheets(1)
wkb1.Activate
For iCounter = ListBox1.ListCount - 1 To 0 Step -1
If ListBox1.Selected(iCounter) And xOpt = 1 Or xOpt = 2 Then
Set XBlatt = Sheets(ListBox1.List(iCounter, 0))
xZeile = Range(ListBox1.List(iCounter, 1)).Row
xCounter = xCounter + 1
XBlatt.Rows(xZeile).Copy wks2.Rows(xCounter)
XBlatt.Rows(xZeile).Delete Shift:=xlUp
ListBox1.RemoveItem (iCounter)
End If
Next iCounter
wks2.Activate
End Sub
Private Sub CommandButton5_Click()
Dim iCounter As Long
If MsgBox("Die markierten Daten werden unwideruflich aus dieser Datei gelöscht." & vbLf & _
"Wollen Sie fortfahren?", vbOKCancel, "Achtung!") = vbOK Then
For iCounter = ListBox1.ListCount - 1 To 0 Step -1
If ListBox1.Selected(iCounter) And xOpt = 1 Or xOpt = 2 Then
Set XBlatt = Sheets(ListBox1.List(iCounter, 0))
xZeile = Range(ListBox1.List(iCounter, 1)).Row
XBlatt.Rows(xZeile).Delete Shift:=xlUp
ListBox1.RemoveItem (iCounter)
End If
Next iCounter
End If
End Sub
Private Sub CommandButton6_Click()
Dim xZeile As Long
If TextBox3 = "" Then Exit Sub
If ComboBox2.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox2.ListIndex + 1
End If
Cells(xZeile, 1) = TextBox3
Cells(xZeile, 2) = TextBox4
TextBox3 = ""
TextBox4 = ""
Columns("A:B").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub Label4_Click()
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Application.Goto Sheets(ListBox1.List(ListBox1.ListIndex, 0)).Range(ListBox1.List(ListBox1. _
ListIndex, 1))
End Sub
Private Sub OptionButton1_Click()
xOpt = 1
End Sub
Private Sub OptionButton2_Click()
xOpt = 2
End Sub
Private Sub TextBox4_Change()
End Sub
Private Sub UserForm_Initialize()
For Each wks In Worksheets
If wks.Name ActiveSheet.Name Then ComboBox1.AddItem wks.Name
Next
Suchart = xlPart
xOpt = 1
Dim aRow, i As Long
Application.EnableEvents = False
ComboBox2.Clear
aRow = [A65536].End(xlUp).Row
ComboBox2.AddItem "neue Kommission hinzufügen"
For i = 2 To aRow
ComboBox2.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox2.ListIndex = 0
Application.EnableEvents = True
End Sub