Anzeige
Archiv - Navigation
824to828
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
824to828
824to828
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

List Eigenschaft

List Eigenschaft
04.12.2006 07:52:55
otto
Hi,
was ist an folgendem Code falsch?
es kommt immer "Laufzeitfehler 381 List-Eigenschaft konnte nicht zugeordnet werden, ungültiger Index-Eigenschaftswert".

Private Sub Übersicht_Click()
Dim ausgewählt, zeile1, c, firstAddress, fund1
ausgewählt = Me.Ident
zeile1 = 0
Sheets("Bestand").Select
With Worksheets("Bestand").Range("y4:y5000")
Set c = .Find(ausgewählt, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Select
fund1 = ActiveCell.Row
Funde.ListBox1.List(zeile1, 0) = Cells(fund1, 4)
Funde.ListBox1.List(zeile1, 1) = Cells(fund1, 5)
Funde.ListBox1.List(zeile1, 2) = Cells(fund1, 25)
Funde.ListBox1.List(zeile1, 3) = Cells(fund1, 24)
Funde.ListBox1.List(zeile1, 4) = Cells(fund1, 27)
zeile1 = zeile1 + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Funde.Show
End Sub

Gruß
otto

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: List Eigenschaft
04.12.2006 08:32:18
Gert
Hallo Otto,
ich habe zwar wenig Kenntnisse von VBA, aber Variablen-Deklaration sieht anders
aus (string, integer, double und variant).
Die Schleife heißt auf deutsch wenn,dann,sonst, In english If, then, else und
nicht If,then,do.
mfg
Gert
AW: List Eigenschaft
04.12.2006 08:45:13
otto
Hi,
Else muss nicht sein wenn ich nur eine Bedingung abfrage. Außerdem hat die If Anweisung nichts mit einer Schleife zu tun, das macht Do .. Loop.
otto
AW: List Eigenschaft
04.12.2006 09:05:14
Heiko
Hallo Otto,
du muß ja auch erstmal eine Zeile einfügen bevor du das was reinschrieben kannst.

Private Sub CommandButton1_Click()
Dim zeile1, c, firstAddress, fund1
zeile1 = 0
ListBox1.Clear
With Worksheets("Bestand").Range("A4:A50")
Set c = .Find(1, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
fund1 = c.Row
ListBox1.AddItem Cells(fund1, 2)
ListBox1.List(zeile1, 1) = Cells(fund1, 2)
ListBox1.List(zeile1, 2) = Cells(fund1, 4)
ListBox1.List(zeile1, 3) = Cells(fund1, 5)
ListBox1.List(zeile1, 4) = Cells(fund1, 6)
zeile1 = zeile1 + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub

Oder besser noch erst alles was du gefunden hast in eine Array schreiben und dann einfach alles in einem Rutsch in die Listbox, z.B. so:
ListBox1.List = MyArray
Gruß Heiko
PS: Rückmeldung wäre nett !
Anzeige
Alles klar
04.12.2006 09:26:46
otto
Hi,
logisch - danke , hatte wohl einen schlechten Start heute.
otto
AW: List Eigenschaft
04.12.2006 09:55:54
otto
Hi,
sorry, geht immer noch nicht.
kannst du das mit dem Array mal als beispiel schicken?
gruß
otto
Fehler gefunden
04.12.2006 10:10:49
otto
Hi,
hatte vergessen am Anfang zeile auf 0 zu setzen.
otto
AW: List Eigenschaft
04.12.2006 10:12:32
Rudi
Hallo,
müsste so klappen:

Private Sub Übersicht_Click()
Dim ausgewählt, zeile1, c, firstAddress, fund1
Dim arrTmp()
ausgewählt = Me.Ident
zeile1 = 1
Sheets("Bestand").Select
With Worksheets("Bestand").Range("y4:y5000")
Set c = .Find(ausgewählt, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
fund1 = c.Row
ReDim Preserve arrTmp(1 To 5, 1 To zeile1)
arrTmp(1, zeile1) = Cells(fund1, 4)
arrTmp(2, zeile1) = Cells(fund1, 5)
arrTmp(3, zeile1) = Cells(fund1, 25)
arrTmp(4, zeile1) = Cells(fund1, 24)
arrTmp(5, zeile1) = Cells(fund1, 27)
zeile1 = zeile1 + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
funde.listbox1.List = WorksheetFunction.Transpose(arrTmp)
funde.Show
End Sub
Gruß
Rudi
Eine Kuh macht Muh, viele Kühe machen Mühe
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige