Automatisierungsfehler
05.06.2019 09:44:36
Patrick
ich bekomme beim Ausführen meines Makros folgende Fehlermeldung:
Ungültige Vorreferenz oder Referenz zu unkompiliertem Typ.
Das Makro soll jedes File mit der Endung .xlsm öffnen und dann ein gewisses Prozedere durchführen.
Anbei der Code. Bei der fetten, kursiven Zeile bekomme ich die erwähnte Fehlermeldung.
WIsst ihr woran das liegen kann?
Danke im Voraus,
Patrick!
Sub Verdichtung_refresh()
Dim wb As Workbook
Dim strmyPath As String
Dim strmyDat As String
Dim ws As Worksheet
strmyPath = "C:Hier steht mein Pfad\"
strmyDat = Dir(strmyPath & "*.xlsm")
Application.ScreenUpdating = False
Application.DisplayAlerts = True
Do While strmyDat ""
Set wb = Workbooks.Open(strmyPath & strmyDat)
For Each ws In ActiveWorkbook.Worksheets
If Left(ws.Name, 4) = "Inp." Then
ws.Select
ws.Cells(3, 3).Select
Selection.AutoFill Destination:=Range("C3:IR3"), Type:=xlFillDefault
ws.Range(ws.Cells(3, 3), ws.Cells(3, 252)).Select
Calculate
Selection.AutoFill Destination:=ws.Range(ws.Cells(3, 3), ws.Cells(6577, 252))
ws.Range(ws.Cells(3, 3), ws.Cells(6577, 252)).Select
Calculate
ws.Cells(4, 3).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next ws
Worksheets("Output").Select
Cells(3, 5).Select
Selection.AutoFill Destination:=Range("E3:IT3"), Type:=xlFillDefault
Range(Cells(3, 5), Cells(3, 254)).Select
Calculate
Selection.AutoFill Destination:=Range(Cells(3, 5), Cells(6577, 254))
Range(Cells(3, 5), Cells(6577, 254)).Select
Calculate
Cells(4, 5).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Close SaveChanges:=True
strmyDat = Dir
Loop
' Application.DisplayAlerts = True
MsgBox "Done"
End Sub