• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

hata alıyorum listbox veri eklerken Run-time error '380':

Katılım
14 Ocak 2005
Mesajlar
807
Excel Vers. ve Dili
Microsoft Office Professional Plus 2021
S.a. arkadaşlar;
aşağıdaki listbox2 ye değerleri ekliyorum. ListBox2.List(Satır, 9) = BUL.Offset(0, 7).Value
buraya gelinceye kadar sorun olmuyor fakat
ListBox2.List(Satır, 10) = BUL.Offset(0, (ay * 2) + 7).Value
bu 10 uncu satırı ekleyince şu hatayı alıyorum.
Run-time error '380':
Could not set the List property. Invalid property value.

Sorun nedir anlayamadım.

Kod:
ListBox2.AddItem
                ListBox2.List(Satır, 0) = BUL.Offset(0, -1).Value
                ListBox2.List(Satır, 1) = BUL.Offset(0, 0).Value
                ListBox2.List(Satır, 2) = BUL.Offset(0, 1).Value
                ListBox2.List(Satır, 3) = BUL.Offset(0, (ay * 2) + 6).Value
                ListBox2.List(Satır, 4) = BUL.Offset(0, 2).Value
                ListBox2.List(Satır, 5) = BUL.Offset(0, 3).Value
                ListBox2.List(Satır, 6) = BUL.Offset(0, 4).Value
                ListBox2.List(Satır, 7) = BUL.Offset(0, 5).Value
                ListBox2.List(Satır, 8) = BUL.Offset(0, 6).Value
                ListBox2.List(Satır, 9) = BUL.Offset(0, 7).Value
                ListBox2.List(Satır, 10) = BUL.Offset(0, (ay * 2) + 7).Value
 
Merhaba,

AddItem yöntemi ile 10 sütunda fazla veri alamazsınız. Rowsource yada dizi yöntemlerini kullanmanız gerekir.
 
Ömer hocam yukarıdaki yöntemime göre alabileceğim dizi yöntemi nasıl kullanabilirm. bir örnek verebilirmisiniz.
 
Sorunuzu destekleyen küçük bir örnek ekleyerek açıklarmısınız.
 
Ömer bey aşağıda ki kodla bulduğum değerin sağındaki solundaki değerleri addItem yöntemi ile listbox2 atıyordum dediğiniz gibi 10 satırı eklemedi hata verdi
Başka nasıl yapabilirim bu işlemi.

Dim BUL As Range, ADRES As String, VERİ As String, Satır As Long
Dim ay As Integer

ay = Sheets("Parametre").Range("B2")

If TextBox9 = "" Then
'ListBox2.RowSource = "MLZ_KOD!B2:E" & Sheets("MLZ_KOD").Cells(Rows.Count, 1).End(3).Row
ListBox2.RowSource = ""
ListBox2.Clear

If OptionButton1 = True Then
VERİ = "A" & "*"
Else
VERİ = "*" & "A" & "*"
End If

Set BUL = Sheets("MLZ_KOD").Range("C:C").Find(VERİ, , , xlWhole)
If Not BUL Is Nothing Then
ADRES = BUL.Address
Do

ListBox2.AddItem
ListBox2.List(Satır, 0) = BUL.Offset(0, -1).Value
ListBox2.List(Satır, 1) = BUL.Offset(0, 0).Value
ListBox2.List(Satır, 2) = BUL.Offset(0, 1).Value
ListBox2.List(Satır, 3) = BUL.Offset(0, (ay * 2) + 6).Value
ListBox2.List(Satır, 4) = BUL.Offset(0, 2).Value
ListBox2.List(Satır, 5) = BUL.Offset(0, 3).Value
ListBox2.List(Satır, 6) = BUL.Offset(0, 4).Value
ListBox2.List(Satır, 7) = BUL.Offset(0, 5).Value
ListBox2.List(Satır, 8) = BUL.Offset(0, 6).Value
ListBox2.List(Satır, 9) = BUL.Offset(0, 7).Value
ListBox2.List(Satır, 10) = BUL.Offset(0, 8).Value

Satır = Satır + 1

Set BUL = Sheets("MLZ_KOD").Range("C:C").FindNext(BUL)
Loop While Not BUL Is Nothing And BUL.Address <> ADRES
End If

If ListBox2.ListCount > 0 Then ListBox2.ListIndex = 0
'Label5.Caption = "LİSTELENEN KAYIT SAYISI = " & Format(ListBox2.ListCount, "#,##0")

Else
ListBox2.RowSource = ""
ListBox2.Clear

If OptionButton1 = True Then
VERİ = TextBox9 & "*"
Else
VERİ = "*" & TextBox9 & "*"
End If

Set BUL = Sheets("MLZ_KOD").Range("C:C").Find(VERİ, , , xlWhole)
If Not BUL Is Nothing Then
ADRES = BUL.Address
Do

ListBox2.AddItem
ListBox2.List(Satır, 0) = BUL.Offset(0, -1).Value
ListBox2.List(Satır, 1) = BUL.Offset(0, 0).Value
ListBox2.List(Satır, 2) = BUL.Offset(0, 1).Value
ListBox2.List(Satır, 3) = BUL.Offset(0, (ay * 2) + 6).Value
ListBox2.List(Satır, 4) = BUL.Offset(0, 2).Value
ListBox2.List(Satır, 5) = BUL.Offset(0, 3).Value
ListBox2.List(Satır, 6) = BUL.Offset(0, 4).Value
ListBox2.List(Satır, 7) = BUL.Offset(0, 5).Value
ListBox2.List(Satır, 8) = BUL.Offset(0, 6).Value
ListBox2.List(Satır, 9) = BUL.Offset(0, 7).Value
ListBox2.List(Satır, 10) = BUL.Offset(0, 8).Value
' ListBox2.List(Satır, 10) = BUL.Offset(0, (ay * 2) + 7).Value

Satır = Satır + 1

Set BUL = Sheets("MLZ_KOD").Range("C:C").FindNext(BUL)
Loop While Not BUL Is Nothing And BUL.Address <> ADRES
End If

If ListBox2.ListCount > 0 Then ListBox2.ListIndex = 0
'Label5.Caption = "LİSTELENEN KAYIT SAYISI = " & Format(ListBox2.ListCount, "#,##0")
End If
 
Merhaba,

Forumumuzda onlarca örnek var.

redim+listbox ifadesi ile arama yapınız.
 
Korhan bey dediğiniz gibi arama yaptım ama daha önce hiç kullanmadım bu yöntemi rica etsem basit bir örnek yapabilirmisiniz.
 
Sayın Korhan Ayhan ve Ömer bey teşekkür ederim ikinizede fikirlerinizden dolayı.
Aşağıdaki gibi yaptım bir kontrol ederseniz bu şekilde oldu. eksik bir yeri varsa düzeltelim.
vay bee 4 saatimi aldı şunu anlamak ve yapmak oysa bilen için ne kadar kolay olsa gerek.

Private Sub TextBox9_Change()
Dim BUL As Range, ADRES As String, VERİ As String, Satir As Long
Dim ay As Integer

Satir = 1

ReDim myarr(1 To 11, 1 To 1)
ay = Sheets("Parametre").Range("B2")

If TextBox9 = "" Then
'ListBox2.RowSource = "MLZ_KOD!B2:E" & Sheets("MLZ_KOD").Cells(Rows.Count, 1).End(3).Row
ListBox2.RowSource = ""
ListBox2.Clear

If OptionButton1 = True Then
VERİ = "A" & "*"
Else
VERİ = "*" & "A" & "*"
End If

Set BUL = Sheets("MLZ_KOD").Range("C:C").Find(VERİ, , , xlWhole)
If Not BUL Is Nothing Then
ADRES = BUL.Address
Do
' eski atama şekli additem yöntemi ile
' ListBox2.AddItem
' ListBox2.List(satir, 0) = BUL.Offset(0, -1).Value
' ListBox2.List(satir, 1) = BUL.Offset(0, 0).Value
' ListBox2.List(satir, 2) = BUL.Offset(0, 1).Value
' ListBox2.List(satir, 3) = BUL.Offset(0, (ay * 2) + 6).Value
' ListBox2.List(satir, 4) = BUL.Offset(0, 2).Value
' ListBox2.List(satir, 5) = BUL.Offset(0, 3).Value
' ListBox2.List(satir, 6) = BUL.Offset(0, 4).Value
' ListBox2.List(satir, 7) = BUL.Offset(0, 5).Value
' ListBox2.List(satir, 8) = BUL.Offset(0, 6).Value
' ListBox2.List(satir, 9) = BUL.Offset(0, 7).Value
' ListBox2.List(satir, 10) = BUL.Offset(0, 8).Value


' bUda redim dizi yöntemi ile
ReDim Preserve myarr(1 To 11, 1 To Satir)
myarr(1, Satir) = BUL.Offset(0, -1).Value
myarr(2, Satir) = BUL.Offset(0, 0).Value
myarr(3, Satir) = BUL.Offset(0, 1).Value
myarr(4, Satir) = BUL.Offset(0, (ay * 2) + 6).Value
myarr(5, Satir) = BUL.Offset(0, 2).Value
myarr(6, Satir) = BUL.Offset(0, 3).Value
myarr(7, Satir) = BUL.Offset(0, 4).Value
myarr(8, Satir) = BUL.Offset(0, 5).Value
myarr(9, Satir) = BUL.Offset(0, 6).Value
myarr(10, Satir) = BUL.Offset(0, 7).Value
myarr(11, Satir) = BUL.Offset(0, (ay * 2) + 7).Value

Satir = Satir + 1

Set BUL = Sheets("MLZ_KOD").Range("C:C").FindNext(BUL)
Loop While Not BUL Is Nothing And BUL.Address <> ADRES

If Satir > 0 Then ListBox2.Column = myarr
End If

If ListBox2.ListCount > 0 Then ListBox2.ListIndex = 0
'Label5.Caption = "LİSTELENEN KAYIT SAYISI = " & Format(ListBox2.ListCount, "#,##0")

Else
ListBox2.RowSource = ""
ListBox2.Clear

If OptionButton1 = True Then
VERİ = TextBox9 & "*"
Else
VERİ = "*" & TextBox9 & "*"
End If

Set BUL = Sheets("MLZ_KOD").Range("C:C").Find(VERİ, , , xlWhole)
If Not BUL Is Nothing Then
ADRES = BUL.Address
Do

' ListBox2.AddItem
' ListBox2.List(satir, 0) = BUL.Offset(0, -1).Value
' ListBox2.List(satir, 1) = BUL.Offset(0, 0).Value
' ListBox2.List(satir, 2) = BUL.Offset(0, 1).Value
' ListBox2.List(satir, 3) = BUL.Offset(0, (ay * 2) + 6).Value
' ListBox2.List(satir, 4) = BUL.Offset(0, 2).Value
' ListBox2.List(satir, 5) = BUL.Offset(0, 3).Value
' ListBox2.List(satir, 6) = BUL.Offset(0, 4).Value
' ListBox2.List(satir, 7) = BUL.Offset(0, 5).Value
' ListBox2.List(satir, 8) = BUL.Offset(0, 6).Value
' ListBox2.List(satir, 9) = BUL.Offset(0, 7).Value
' ListBox2.List(satir, 10) = BUL.Offset(0, 8).Value
' ListBox2.List(satir, 10) = BUL.Offset(0, (ay * 2) + 7).Value



ReDim Preserve myarr(1 To 11, 1 To Satir)
myarr(1, Satir) = BUL.Offset(0, -1).Value
myarr(2, Satir) = BUL.Offset(0, 0).Value
myarr(3, Satir) = BUL.Offset(0, 1).Value
myarr(4, Satir) = BUL.Offset(0, (ay * 2) + 6).Value
myarr(5, Satir) = BUL.Offset(0, 2).Value
myarr(6, Satir) = BUL.Offset(0, 3).Value
myarr(7, Satir) = BUL.Offset(0, 4).Value
myarr(8, Satir) = BUL.Offset(0, 5).Value
myarr(9, Satir) = BUL.Offset(0, 6).Value
myarr(10, Satir) = BUL.Offset(0, 7).Value
myarr(11, Satir) = BUL.Offset(0, (ay * 2) + 7).Value

Satir = Satir + 1

Set BUL = Sheets("MLZ_KOD").Range("C:C").FindNext(BUL)
Loop While Not BUL Is Nothing And BUL.Address <> ADRES

If Satir > 0 Then ListBox2.Column = myarr

End If

If ListBox2.ListCount > 0 Then ListBox2.ListIndex = 0
'Label5.Caption = "LİSTELENEN KAYIT SAYISI = " & Format(ListBox2.ListCount, "#,##0")
End If
End Sub
 
Geri
Üst