I can configure the autofilter using pyWin32, but I wondered if the default filter could be set and what the syntax would be.
For example, I would like to set the filter in the year column and set the default value for the current year.
xl = Dispatch("Excel.Application")
xl.Workbooks.Open(file_path)
xl.ActiveWorkbook.Worksheets(sheetname).Range("A2:A6").AutoFilter(1)
xl.ActiveWorkbook.Close(SaveChanges=1)
I looked at the pywin32 documentation online as well as the Microsofts website, but cannot figure out how to translate the MS syntax to pywin32
Range("A2:A6").AutoFilter Field:=1, Criteria1:=rng.Value
source
share