我尝试过滤L列,所以我只能获取去年和今年之间的数据。下面是我的代码: 子过滤器()
Dim LastRow As Long
Dim previousyear As Integer
Dim currentyear As Integer
currentyear = Year(Date)
previousyear = Year(Date) - 1
ldatefrom = DateSerial(previousyear, 1, 1)
ldateto = DateSerial(currentyear, 12, 31)
LastRow = Range("A1").CurrentRegion.Rows.Count
Range("A1:CA" & LastRow).Select
Selection.AutoFilter Field:=12, Criteria1:=">=" & ldatefrom, _
Operator:=xlFilterValues, _
Criteria2:="<=" & ldateto
Selection.SpecialCells(xlCellTypeVisible).Copy
Dim dest As Range
With Workbooks("data.xlsm").Worksheets(5)
Set dest = .Range("A1")
Selection.SpecialCells(xlCellTypeVisible).Copy dest
End With
End Sub
它没有给我任何结果。怎么了?