Option Explicit
Sub filterAndTransfer()
Dim target As Range
Windows("Another workbook").Activate
With Worksheets("sheet1")
Set target = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With
Windows("Workbook" & Format(Date, "mmmmyy")).Activate
With Worksheet("1")
.Unprotect
If .AutoFilterMode Then .AutoFilterMode = False
With .Cells(1, "A").CurrentRegion
.Sort Key1:=.Cells(1, "D"), Order1:=xlDescending, DataOption1:=xlSortNormal, _
Orientation:=xlTopToBottom, Header:=xlYes
.AutoFilter field:=1, Criteria1:=0
.Offset(1, 0).Copy Destination:=target
End With
If .AutoFilterMode Then .AutoFilterMode = False
End With
End Sub
我收到以下错误消息: 可以抛出呼叫,但未将其标记为“ try”,并且未处理错误