Add Autofilter

     

  • Enabels to add the AUTOFILTER
  •  

    Private Sub CommandButton1_Click()
    'add autofilter
    Range("A1").AutoFilter
    End Sub

    Private Sub CommandButton2_Click()
    'remove autofilter
    'Range("A1").AutoFilter
    ActiveSheet.AutoFilterMode = False
    End Sub

     

     

     

    Monthly Report

     

    Private Sub CommandButton2_Click()
    b = ComboBox2.Value
    c = ComboBox3.Value
    Condition = b & c
    Sheets("Sheet3").UsedRange.Clear
    e = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row
    last = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
    For q = 2 To last
    Sheets("Sheet2").Activate
    mmm = MonthName(Month(Range("B" & q).Value))
    yyy = Year(Range("B" & q).Value)
    inputs = mmm & yyy
    If (Condition = inputs) Then
    Range(Cells(q, 1), Cells(q, 7)).Select
    Selection.Copy Destination:=Sheets("Sheet3").Range("A" & e)
    End If
    e = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row + 1
    Application.StatusBar = q
    Sheets("Sheet3").Activate
    Next
    Sheets("Sheet2").Rows(1).Copy Sheets(3).Range("A1")
    Sheets("Sheet3").UsedRange.Columns.AutoFit
    End Sub