Suchcode verkürzen
08.07.2008 07:39:00
otto
kann man folgenden Code noch verkürzen?
Private Sub suchen()
Dim suchbegriff, fund2, bereich As Range, fundfund, bereichnds As Range
Sheets("Bestand").Select
Set bereich = Range("y2:y20000")
suchbegriff = Start.Ident
Dim p1 As Currency, p2 As Currency, pg As Currency
With bereich
Set c = .Find(suchbegriff, LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlPrevious)
If Not c Is Nothing Then
firstaddress = c.Address
Dim zli
zli = 0
Do
fund2 = c.Row
If fund2 = fundfund Then GoTo weitersuchen 'wenn in gleicher Zeile nochmals _
gefunden dann weitersuchen
ListBox1.AddItem fund2
ListBox1.List(zli, 0) = Format(Cells(fund2, 47), "0")
ListBox1.List(zli, 1) = Cells(fund2, 53)
ListBox1.List(zli, 2) = Format(Cells(fund2, 63), "0")
ListBox1.List(zli, 3) = Cells(fund2, 61)
ListBox1.List(zli, 4) = Format(Cells(fund2, 39), "0.00")
ListBox1.List(zli, 5) = Format(Cells(fund2, 40), "0.00")
zli = zli + 1
fundfund = fund2
If zli >= 20 Then
If Cells(fund2, 61) firstaddress
End If
End With
ListBox1.ColumnWidths = "40;50;80;50;70;40"
Me.Caption = "Auflistung zu: >" & suchbegriff & " "" Then GoTo üanzeigen
Exit Sub
üanzeigen:
ListBox1.Height = 338
End Sub
Gruß
otto