ich möchte ca20 Vorlagen von einer Datei in eine andere Datei kopieren.
Die beigefügte Sub ist sehr langsam. Geht das irgendwie schneller und
auch so, dass es unter einer Excelversion über 2003 funktioniert?
Danke im voraus
Peter
Option Explicit
Sub Vorl_Import()
Dim WkbQ As Workbook
Dim sFile As String
Dim i As Integer, wsName As String, sName As String
Dim ShGrund As Worksheet, wks As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ShGrund = Worksheets("Grunddaten")
sFile = ShGrund.Range("A22")
sName = ShGrund.Range("A23")
'sFile = "G:\Vorlagen\QuellVorlagen.xls"
'sName = "Vorl"
If Dir(sFile) = "" Then
Beep
MsgBox "Datei wurde nicht gefunden!"
Exit Sub
End If
For Each wks In Worksheets
If InStr(wks.Name, sName) > 0 Then wks.Delete
Next wks
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Set WkbQ = Workbooks.Open(sFile, False)
For Each wks In WkbQ.Worksheets
With wks 'QuellVorlagen
If Left(.Name, 4) = sName Then
'## -Fehler#########- wenn aktiviert,wird die Quelldatei nicht geschlossen
' .Visible = False
.Copy after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
End If
End With
Next
WkbQ.Close savechanges:=False
'Call Vorl_NotVisible
ERRORHANDLER:
Application.DisplayAlerts = False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Sub Vorl_NotVisible()
Dim wks As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each wks In ThisWorkbook.Worksheets
With wks 'QuellVorlagen
If Left(.Name, 4) = "Vorl" Then
.Visible = False
End If
End With
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End