我正在尝试在对表格进行过滤(自动过滤)后将其从表格复制到另一表格。输入是一个工作簿(带有Quelldatei),而不是创建另外两个工作表“ FSS”和“ GMS_PC.A157”。
Dim Pfad1 As String
Dim Bezeichnung As Variant
Umsatzdatenbank = ActiveWorkbook.Name
Pfad1 = Workbooks(Umsatzdatenbank).Sheets("Umsatz").Cells(5, 5)
Set range4 = Workbooks(Umsatzdatenbank).Sheets("Filter").Range("C3:C" & lastbez2)
Set range5 = Workbooks(Umsatzdatenbank).Sheets("Filter").Range("F3:F" & lastoffice)
lastbez2 = Workbooks(Umsatzdatenbank).Sheets("Filter").Range("C" & Rows.Count).End(xlUp).Row
lastoffice2 = Workbooks(Umsatzdatenbank).Sheets("Filter").Range("F" & Rows.Count).End(xlUp).Row
Dim sArray4, sArray5 As Variant
sArray4 = copyToArray(range4)
sArray5 = copyToArray(range5)
Workbooks.Open Pfad1
ActiveSheet.Name = "Quelldatei"
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Name = "GMS_PC.A157"
With Worksheets("GMS_PC.A157")
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("K1").Select
Selection.AutoFilter
Worksheets("GMS_PC.A157").Range("$A$1:$AA$" & LastRow).AutoFilter Field:=11, Criteria1:=sArray4, Operator:=xlFilterValues
Worksheets("GMS_PC.A157").Range("$A$1:$AA$" & LastRow).AutoFilter Field:=13, Criteria1:=sArray5, Operator:=xlFilterValues
Worksheets("GMS_PC.A157").Range("$A$1:$AA$" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Copy
On Error Resume Next
Worksheets("GMS_PC.A157").Range("$A$1:$AA$" & LastRow).PasteSpecial xlPasteValues 'error line'
On Error GoTo 0
End With