• DİKKAT

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

Listbox ile alakalı bir döngü

  • Konbuyu başlatan Konbuyu başlatan harziyan
  • Başlangıç tarihi Başlangıç tarihi
Katılım
13 Aralık 2006
Mesajlar
575
Excel Vers. ve Dili
Office 2010
Merhabalar;
Aşağıdaki kodlarda bir sorun yok, lakin liste uzadıkça, yazması hem zaman alıyor, hem de belli bir müddet sonra kontrol edemiyorum. Talebim, bir döngü ile bu kodların kısaltılıp kısaltılamayacağıdır!

Teşekkürler.
Kod:
If ListBox5.List(0, 0) = "" Then
Sheets("tge").[b15].Value = ""
Else
Sheets("tge").[b15].Value = ListBox5.List(0, 0)
End If

If ListBox5.List(1, 0) = "" Then
Sheets("tge").[b15].Value = ListBox5.List(0, 0)
Else
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0)
End If

If ListBox5.List(2, 0) = "" Then
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0)
Else
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0) & ", " & ListBox5.List(2, 0)
End If

If ListBox5.List(3, 0) = "" Then
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0) & ", " & ListBox5.List(2, 0)
Else
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0) & ", " & ListBox5.List(2, 0) & ", " & ListBox5.List(3, 0)
End If

If ListBox5.List(4, 0) = "" Then
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0) & ", " & ListBox5.List(2, 0) & ", " & ListBox5.List(3, 0)
Else
Sheets("tge").[b15].Value = ListBox5.List(0, 0) & ", " & ListBox5.List(1, 0) & ", " & ListBox5.List(2, 0) & ", " & ListBox5.List(3, 0) & ", " & ListBox5.List(4, 0)
 
Destek Eibinden Systran'a çok teşekkür ederim. Aşağıdaki kodla işimi halletti.
Kod:
tmpStr = ""
tekrar = ListBox5.ListCount - 1
For i = 0 To tekrar
    
    icerik = Controls("ListBox5").List(i, 0)
    If icerik <> "" Then
        tmpStr = tmpStr & icerik & ","
    End If
    
Next i
tmpStr = Left(tmpStr, Len(tmpStr) - 1)
MsgBox tmpStr
 
Geri
Üst