Ohne deine Datei ist das schwierig, wegen Testen. Also ohne Garantie. Der Fehler könnte gewesen sein, das Cells und Range ohne vorangestellte Sheetbezeichnung immer auf das aktive Sheet zeigt. Somit auf das Neuerstellte mit den Filterergebnissen.
Sub Reasoncode30()
Dim fd As Office.FileDialog
Dim last_Row As Long
Dim last_Column As Long
Dim i As Long
Dim j As Long
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Title = "Bitte Mandant: " & Mandant & " auswählen"
.Filters.Add "Excel Files", "*.xlsx?", 1
.AllowMultiSelect = False
Dim sFile As String
If .Show Then sFile = .SelectedItems(1)
End With
Application.ScreenUpdating = False
If sFile = "" Then Exit Sub
Set ext_produkt = Workbooks.Open(sFile)
'Ganze Spalte
With Worksheets("F01")
last_Row = .Cells(.Rows.Count, 3).End(xlUp).Row
.Cells(1, .Range("H1").Column).AutoFilter .Range("H1").Column, "TB", Operator:=xlAnd, VisibleDropDown:=True
.Cells(1, .Range("BO1").Column).AutoFilter .Range("BO1").Column, 30, Operator:=xlAnd, VisibleDropDown:=True
End With
Worksheets.Add
ActiveSheet.Name = "SB und TB Auftrag"
Worksheets("F01").Range("A1:BY" & last_Row).Copy Destination:=ActiveSheet.Range("A1")
Dim wks As Worksheet
For Each ws In Worksheets
If ws.AutoFilterMode Then
ws.AutoFilterMode = False
End If
Next ws
With Worksheets("F01")
.Activate
If Not .AutoFilterMode = True Then
.Cells(m, .Range("H1").Column).AutoFilter .Range("H1").Column, "WB", Operator:=xlAnd, VisibleDropDown:=True
.Cells(m, .Range("BO1").Column).AutoFilter .Range("BO1").Column, 30, Operator:=xlAnd, VisibleDropDown:=True
Worksheets.Add
ActiveSheet.Name = "WB Auftrag"
.Range("A1:BY" & last_Row).Copy Destination:=ActiveSheet.Range("A1")
End If
End With
Application.ScreenUpdating = True
End Sub
|