• DİKKAT

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

Çözüldü Range("a2:a3","c2:c3","d2:d3") sorun

  • Konbuyu başlatan Konbuyu başlatan FERAZ
  • Başlangıç tarihi Başlangıç tarihi
Sorunuzu çok iyi anlamadım ama Dim aa() satırını silip deneyin.
 
Evet sorum biraz katıştı resimden dolayı.
Mantken mesela
Bir dizinin içine A,C ve E sütunlarını aldırmak istiyorum örnekteki gibi.
 
"Union" komutunu inceleyiniz.
 
Korhan hocam Union aklıma gelmiş ve denemiş ve sonuç olarak yapamamıştım.
Çözümü paylaşır mısınız rica etsem.
 
Uniona göre yaptım resimdeki gibi olmadı istediğim.

 
Ne yapmaya çalışıyorsunuz?
 
aa = Range("A2:E" & son).Value

Böyle yazmak istemiyorum.Bana A,C ve E lazım.


aa = Range("A2:E" & son).Value böyle yazıp döngü ile çekebilirim fakat B ve D sütunlarını istemiyorum.

 
Dahada anlatmak gerekirse.En alttaki kod yerine

Bu şekilde kullanmak istiyorum açıkçası.Biraz fantazi ama vardır belki bir yolu diye sorayım istedim.

Private Sub CommandButton1_Click()

Dim aa(), arr()
ListBox1.ColumnCount = 3
ListBox1.Clear
son = Range("A" & Rows.Count).End(3).Row
aa = Range("A2:A" & son,"C2:C" & son,"E2:E" & son").Value

ReDim arr(1 To son, 1 To 3)
For i = LBound(aa) To UBound(aa)
arr(i, 1) = aa(i, 1)
arr(i, 2) = aa(i, 2)
arr(i, 3) = aa(i, 3)
Next

ListBox1.List = arr

End Sub




Kod:
Dim aa(), arr()
ListBox1.ColumnCount = 5
ListBox1.Clear
son = Range("A" & Rows.Count).End(3).Row
aa = Range("A2:E" & son).Value

ReDim arr(1 To son, 1 To 5)
For i = LBound(aa) To UBound(aa)
    arr(i, 1) = aa(i, 1)
    arr(i, 2) = aa(i, 3)
    arr(i, 3) = aa(i, 5)
Next

ListBox1.List = arr

End Sub
 
Şöyle yazın.:cool:
Kod:
aa = Range("A2:A" & son & ",C2:C" & son & ",E2:E" & son).Value
 
6.cı mesajdaki sonuç çıktı ve malisef sayın hocam.
 
Alternatif-1:

Kod:
Private Sub CommandButton1_Click()
    ListBox1.ColumnCount = 5
    ListBox1.ColumnWidths = "60;0;60;0;60"
    ListBox1.Clear
    son = Range("A" & Rows.Count).End(3).Row
    ListBox1.List = Range("A2:E" & son).Value
End Sub


Alternatif-2:

Kod:
Private Sub CommandButton1_Click()
    ListBox1.ColumnCount = 3
    ListBox1.ColumnWidths = "60;60;60"
    ListBox1.Clear
    son = Range("A" & Rows.Count).End(3).Row
    For i = 0 To son - 1
        With Me.ListBox1
            .AddItem
            .List(i, 0) = Range("A" & i + 2)
            .List(i, 1) = Range("C" & i + 2)
            .List(i, 2) = Range("E" & i + 2)
        End With
    Next
End Sub

.
 
Ben bu tür tabloları Array fonksiyonunu kullanarak dizi boyutunda kullanıyorum.

Kod:
Sub buton()
Dim aa(), arr()
son = Range("A" & Rows.Count).End(3).Row
aa = Array(Range("A2:A" & son).Value, Range("C2:C" & son).Value, Range("D2:D" & son).Value)
ListBox1.ColumnCount = UBound(aa) + 1
ListBox1.Clear
ReDim arr(1 To son, 1 To UBound(aa) + 1)
    For i = 1 To son - 1
        For j = 0 To UBound(aa)
            arr(i, j + 1) = aa(j)(i, 1)
        Next j
    Next i
ListBox1.List = arr
End Sub
 
Benim yazdığım kod 6ncı mesajla ayni değil.
Ben denedim hata vermedi.:cool:
 
Alternatif-1:

Kod:
Private Sub CommandButton1_Click()
    ListBox1.ColumnCount = 5
    ListBox1.ColumnWidths = "60;0;60;0;60"
    ListBox1.Clear
    son = Range("A" & Rows.Count).End(3).Row
    ListBox1.List = Range("A2:E" & son).Value
End Sub


Alternatif-2:

Kod:
Private Sub CommandButton1_Click()
    ListBox1.ColumnCount = 3
    ListBox1.ColumnWidths = "60;60;60"
    ListBox1.Clear
    son = Range("A" & Rows.Count).End(3).Row
    For i = 0 To son - 1
        With Me.ListBox1
            .AddItem
            .List(i, 0) = Range("A" & i + 2)
            .List(i, 1) = Range("C" & i + 2)
            .List(i, 2) = Range("E" & i + 2)
        End With
    Next
End Sub

.
Haluk hocam sağolun.Ben dizi olarak kullanmak istiyorum.Alternatif-1 işe yaramıyor.Alternatif-2 de ise Range("A" & i + 2) gibi range olayı kullanmak istemiyorum hız olayı için.
 
Sonuçta önemli olan A, C ve E sütunlarındaki verilerin hızlıca ListBox'da listelenmesi değil mi?

Alternatif-1'den daha hızlısını zor bulursunuz...

.
 
Ben bu tür tabloları Array fonksiyonunu kullanarak dizi boyutunda kullanıyorum.

Kod:
Sub buton()
Dim aa(), arr()
son = Range("A" & Rows.Count).End(3).Row
aa = Array(Range("A2:A" & son).Value, Range("C2:C" & son).Value, Range("D2:D" & son).Value)
ListBox1.ColumnCount = UBound(aa) + 1
ListBox1.Clear
ReDim arr(1 To son, 1 To UBound(aa) + 1)
    For i = 1 To son - 1
        For j = 0 To UBound(aa)
            arr(i, j + 1) = aa(j)(i, 1)
        Next j
    Next i
ListBox1.List = arr
End Sub

Bu kod tam olmuş.Sadece listboxun en altına boşluk ekliyor.

sağolun.
 
Hız için böyle yapın.
Ekli dosyayı deneyin.:cool:

DOSYA İNDİR

Kod:
Private Sub UserForm_Initialize()
Dim aa(), son As Long
son = 4
ListBox1.ColumnCount = 6
ListBox1.ColumnWidths = "50;0;50;0;50"
ListBox1.RowSource = "A2:E4"
End Sub
 
Geri
Üst