• DİKKAT

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

Koşula Göre Satır Sütun Gizleme ve Gösterme

Believing

Altın Üye
Katılım
19 Mayıs 2013
Mesajlar
703
Excel Vers. ve Dili
Office Pro 2019 TR 32 Bit
Windows Pro 10 TR 64 Bit
Sayın uzman arkadaşlar,

Ekteki çalışmada seçenekli üç adet listbox hazırladım. Listbox seçimlerine göre satır - sütun gizlemek veya göstermek istiyorum. Kodlama konusunda benim için çok değerli olan yardımlarınızı rica ederim.

Saygılarımla.

Örnek Çalışma Linki:
 

Ekli dosyalar

Kod:
Private Sub UserForm_Initialize()

    With Worksheets("Parametre")
        ListBox2.List = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row).Value
        ListBox3.List = .Range("B2:B" & .Range("B" & .Rows.Count).End(xlUp).Row).Value
        ListBox4.List = .Range("C2:C" & .Range("C" & .Rows.Count).End(xlUp).Row).Value
    End With

    Worksheets("MAINPAGE").Columns.Hidden = False
End Sub

Private Sub CheckBox1_Change()
    Dim i As Integer
    For i = 0 To ListBox2.ListCount - 1
        ListBox2.Selected(i) = CheckBox1.Value
    Next i
End Sub

Private Sub CheckBox2_Change()
    Dim i As Integer
    For i = 0 To ListBox3.ListCount - 1
        ListBox3.Selected(i) = CheckBox2.Value
    Next i
End Sub

Private Sub CheckBox3_Change()
    Dim i As Integer
    For i = 0 To ListBox4.ListCount - 1
        ListBox4.Selected(i) = CheckBox3.Value
    Next i
    MsgBox ListBox2.Contains(ListBox1.Items.Item)
End Sub

Private Sub CommandButton5_Click()
    
    Dim yil, ay, dept
    Dim i As Long, j As Long, k As Long
    
    With Worksheets("Parametre")
        yil = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row).Value
        ay = .Range("B2:B" & .Range("B" & .Rows.Count).End(xlUp).Row).Value
        dept = .Range("C2:C" & .Range("C" & .Rows.Count).End(xlUp).Row).Value
    End With

    With Worksheets("MAINPAGE")
        For i = 0 To ListBox2.ListCount - 1
            If ListBox2.Selected(i) Then j = j + 1
        Next i
        If j > 0 Then
            For k = 7 To 53
                If UBound(Filter(Application.Transpose(yil), .Cells(4, k))) > -1 Then
                    .Columns(k).Hidden = Not (ListBox2.Selected(Application.Match(.Cells(4, k), ListBox2.List, 0) - 1))
                End If
            Next k
        End If
        
        j = 0
        For i = 0 To ListBox3.ListCount - 1
            If ListBox3.Selected(i) Then j = j + 1
        Next i
        If j > 0 Then
            For k = 7 To 53
                If UBound(Filter(Application.Transpose(ay), .Cells(5, k))) > -1 Then
                    .Columns(k).Hidden = Not (ListBox3.Selected(Application.Match(.Cells(5, k), ListBox3.List, 0) - 1))
                End If
            Next k
        End If
    
        j = 0
        For i = 0 To ListBox4.ListCount - 1
            If ListBox4.Selected(i) Then j = j + 1
        Next i
        If j > 0 Then
            For k = 6 To 200
                If Application.Trim(.Cells(k, 1)) <> "" Then
                    If UBound(Filter(Application.Transpose(dept), .Cells(k, 1))) > -1 Then
                        .Rows(k).Hidden = Not (ListBox4.Selected(Application.Match(.Cells(k, 1), ListBox4.List, 0) - 1))
                    End If
                End If
            Next k
        End If
    
    End With
    
End Sub

Private Sub CommandButton6_Click()
    Unload Me
End Sub

Private Sub CommandButton7_Click()
    With Worksheets("MAINPAGE")
        .Rows.Hidden = False
        .Columns.Hidden = False
    End With
End Sub
 
checkbox'lar için kod ekledim.
iki commandbutton ekledim. formu kapatmak ve gizli satır sütunları açmak için.

4. satır ve 5. satırda bulunan sütun gizleme kriterleriniz çelişiyor.
biri gizlerken diğer açıyor.
bunun ile ilgili kodlara tam ihtiyacınıza göre ilave yapmanız gerekir.
 
Geri
Üst