• DİKKAT

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

Makro ile sayı yuvarlama ve ortak filtre

Katılım
12 Ağustos 2013
Mesajlar
65
Excel Vers. ve Dili
Excel 2016 Türkçe, Excel 2010 Türkçe
Merhabalar,
Elimdeki Userform'da Checkbox'lara girdiğim değeri listeleyen bir listbox var.
Sizden iki konuda yardım isteyeceğim.
1. Fiyat kısmında tüm fiyatların virgülden sonra 2 basamak ve sonunda "TL" yazacak şekilde yapılabilir mi? Değerleri aldığı fiyat sütunundaki hücre formatını sabit yapamıyorum çünkü onu da başka bir makro ile yazdırıyorum.
2. Userformdaki checkboxların ikisine birden filtre yapamadım. Örneğin Alexander Mcqueen müşterisinin Mayıs ayındaki siparişlerini görüntülemek istiyorum.

Yardımcı olabilir misiniz? Benim için acil bir konu.

Teşekkürler.
 

Ekli dosyalar

KOD:

Kod:
Private Sub ComboBox1_Change()
    Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox1.Text = "" Then Exit Sub

    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
        If ComboBox1.Text = Cells(i, "C") Then
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
            dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            'dizial(4, a) = Cells(i, "E")
            dizial(5, a) = Cells(i, "E").Row
            

        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub

Private Sub ComboBox2_Change()
    Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox2.Text = "" Then Exit Sub

    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
        If ComboBox2.Text = Cells(i, "B") And ComboBox1.Text = Cells(i, "C") Then
        'MsgBox ComboBox1.Text & Chr(10) & Cells(i, "C")
      
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
           dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            dizial(5, a) = Cells(i, "E").Row
       
        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub
 
Merhaba halit3 hocam,
Eline sağlık istediğimi yapıyor fakat sadece tarihe göre de filtre yapabilsin istiyorum. Yani 3 filtre olmalı:
1.Sadece tarihe göre,
2.Sadece müşteriye göre,
3. Hem müşteriye hem de tarihe göre.

Bu konuda yardımcı olabilir misin?
Teşekkürler.
 
bunu bir dene

Kod:
Private Sub ComboBox1_Change()
    Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox1.Text = "" Then Exit Sub

    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
    If ComboBox2.Text = "" Then
        If ComboBox1.Text = Cells(i, "C") Then
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
            dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            'dizial(4, a) = Cells(i, "E")
            dizial(5, a) = Cells(i, "E").Row

            
        End If
        Else
        
            If ComboBox2.Text = Cells(i, "B") And ComboBox1.Text = Cells(i, "C") Then
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
            dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            'dizial(4, a) = Cells(i, "E")
            dizial(5, a) = Cells(i, "E").Row

            
        End If
        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub

Private Sub ComboBox2_Change()
    Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox2.Text = "" Then Exit Sub

    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
      If ComboBox1.Text <> "" Then
    If ComboBox2.Text = Cells(i, "B") And ComboBox1.Text = Cells(i, "C") Then
        
        'MsgBox ComboBox1.Text & Chr(10) & Cells(i, "C")
      
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
           dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            dizial(5, a) = Cells(i, "E").Row
       
        End If
        
        If ComboBox2.Text = Cells(i, "B") Then
        'MsgBox ComboBox1.Text & Chr(10) & Cells(i, "C")
      
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
           dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            dizial(5, a) = Cells(i, "E").Row
       
        End If
        
        Else
        
        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub
 
Maalesef bu da çalışmadı halit3 hocam seni de yordum ama nasıl yapılacağı konusunda hiçbir fikrim yok, biraz daha araştırmam gerek sanırım.
 
Kodların hepsini silin Userforma bir adet CommandButton1 ekleyin ve aşağıdaki kodları userforma yapıştırın

Çalışam durumu ComboBox1 ve ComboBox2 dolu olduğunda CommandButton1 çalışacaktır diğer taraftan isim ile sorgularken tarih boş olmalı veya tarih ile sorgulama yaparken isim boş olmalı.


Kod:
Private Sub ComboBox1_Click()
    Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox1.Text = "" Then Exit Sub
If ComboBox2.Text <> "" Then Exit Sub
    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
        If ComboBox1.Text = Cells(i, "C") Then
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
            dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            'dizial(4, a) = Cells(i, "E")
            dizial(5, a) = Cells(i, "E").Row

            
        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub


Private Sub ComboBox2_Click()
    Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox2.Text = "" Then Exit Sub
    If ComboBox1.Text <> "" Then Exit Sub

    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
        If ComboBox2.Text = Cells(i, "B") Then
        'MsgBox ComboBox1.Text & Chr(10) & Cells(i, "C")
      
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
           dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            dizial(5, a) = Cells(i, "E").Row
       
        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub



Private Sub CommandButton1_Click()
   Dim a      As Long
    Dim i      As Long
    ReDim dizial(1 To 5, 1 To 1)

    If ComboBox1.Text = "" Then Exit Sub
If ComboBox2.Text = "" Then Exit Sub


    ListBox1.Clear

    For i = 3 To [C65536].End(3).Row
        If ComboBox1.Text = Cells(i, "C") And ComboBox2.Text = Cells(i, "B") Then
        'MsgBox ComboBox1.Text & Chr(10) & Cells(i, "C")
      
            a = a + 1
            ReDim Preserve dizial(1 To 5, 1 To a)
            dizial(1, a) = Cells(i, "B")
            dizial(2, a) = Cells(i, "C")
            dizial(3, a) = Cells(i, "D")
           dizial(4, a) = Format(Round(Cells(i, "E"), 2) * 1, "###.00") & " TL"
            dizial(5, a) = Cells(i, "E").Row
       
        End If
    Next i

    If a = 0 Then
        MsgBox ComboBox1.Text & " Veri Tablosunda Yok! ", vbCritical
    Else
        ListBox1.Column = dizial
    End If

    Erase dizial
    a = Empty
    i = Empty
    Set SV = Nothing
End Sub

Private Sub UserForm_Initialize()
    With ComboBox1
        .RowSource = ""
        .RowSource = "veriler!A3:A" & Sheets("veriler").[A65536].End(3).Row
    End With
    
    With ComboBox2
        .RowSource = ""
        .RowSource = "veriler!C3:C" & Sheets("veriler").[C65536].End(3).Row
    End With

    With ListBox1
        .Clear
        .ColumnCount = 5
        .ColumnWidths = "120;165;110;120;0"
    End With
End Sub
 
Eline sağlık tam olarak istediğim şeydi, çok teşekkürler.
 
Geri
Üst