[Solved] Macro code to generate a formatted Excel


Try it like this.

Public Sub MyFilter()
    Dim lngStart As Long, lngEnd As Long
    lngStart = Range("E1").Value 'assume this is the start date
    lngEnd = Range("E2").Value 'assume this is the end date
    Range("C1:C13").AutoFilter field:=1, _
        Criteria1:=">=" & lngStart, _
        Operator:=xlAnd, _
        Criteria2:="<=" & lngEnd
End Sub

All details are here.

https://www.extendoffice.com/documents/excel/910-excel-filter-between-two-dates.html

solved Macro code to generate a formatted Excel