ich habe eine Prozedur abgeschrieben um Daten in Abhängigkeit eines Suchbegriffes
in eine Listbox zu schreiben. Beim Klick auf den CommandButton1 hängt sich der Computer jedesmal auf.
Die UserForm hat eine Listbox1, eine Textbox1 und einen Commandbutton1.
Der Code:
Private Sub CommandButton1_Click()
Dim rngCell As Range
Dim strFirstAddress As String
With Worksheets("Tabelle1").Range("A2:A")
Me.ListBox1.Clear
Set rngCell = .Find(Me.TextBox1.Value, LookIn:=xlValues, lookat:=xlPart)
If Not rngCell Is Nothing Then
strFirstAddress = rngCell.Address
Do
With Me.ListBox1
.ColumnCount = 4
.AddItem
.List(.ListCount - 1, 0) = rngCell.Value
.List(.ListCount - 1, 1) = rngCell.Offset(0, 1).Value
.List(.ListCount - 1, 2) = rngCell.Offset(0, 2).Value
.List(.ListCount - 1, 3) = rngCell.Offset(0, 3).Value
.ColumnWidths = "3cm;3cm;3cm;3cm"
End With
Set rngCell = .FindNext(rngCell)
Loop While Not rngCell Is Nothing And rngCell.Address strFirstAddess
Else
MsgBox " Mieter nicht gefunden", 48
End If
End With
End Sub
Wer kann mir hier helfen?Gruß Wolfgang