30.06.2016, 18:04
Hallo ihr Experten!
Ich brauch mal wieder eure hilfe!
Ich muß ca. 400 Tabellen ändern. Für die Änderungen habe ich mir ein Makro aufgezeichnet und aus einen alten Makro was hinzugefügt.
Nach dem durchlaufen des Cods bekomme ich einen Laufzeitfehler"9" Index auserhalb des gültigen Bereiches.
Was habe ich falsch gemacht?
Ich brauch mal wieder eure hilfe!
Ich muß ca. 400 Tabellen ändern. Für die Änderungen habe ich mir ein Makro aufgezeichnet und aus einen alten Makro was hinzugefügt.
Nach dem durchlaufen des Cods bekomme ich einen Laufzeitfehler"9" Index auserhalb des gültigen Bereiches.
Was habe ich falsch gemacht?
Code:
Sub Planändern()
' Planändern Makro
'
Application.ScreenUpdating = False
Dim Maschinen
Dim ordner
Dim y As Integer
Const Verzeichnis = "F:\Wartungspläne\Boy\"
' Maschine = Array("Boy 30.01 M\Boy 30.01 M - S 1485 EP.xls", _
"Boy 50.01 M\Boy 50.01 M - S 1409 EP.xls")
Maschine = Array("Boy 30.01 M\", _
"Boy 50.01 M\")
ordner = Array("Boy 30.01 M - S 1485 EP.xls", _
"Boy 50.01 M - S 1409 EP.xls")
For y = 0 To UBound(Maschine) & UBound(ordner)
Application.StatusBar = "Öffne " & Maschine(y) & ordner(y) & "...."
Workbooks.Open Filename:=Verzeichnis & Maschine(y) & ordner(y)
' Tabellenblatt auswählen
' Dim name As String
' name = DieseArbeitsmappe.Sheets(1) '.Range("QUARTALE").Offset(DieseArbeitsmappe.Sheets(2).Range("Quartal").Value - 1, 0).Value
' ActiveWorkbook.Sheets(name).Select
' Jahr einfügen
' Range("H1").FormulaR1C1 = DieseArbeitsmappe.Sheets(3).Range("Jahre").Offset(DieseArbeitsmappe.Sheets(2).Range("Jahr").Value - 1, 0)
' Application.StatusBar = "Speichere " & maschine(y) & "...."
' ActiveWindow.SelectedSheets.PrintOut Copies:=1
' With ActiveWorkbook
' .Save
' .Close
' End With
'
Blatt = ordner(y)
Windows("Vorlage_SGM11.xlsm").Activate
Sheets("Wartungsplan").Select
Cells.Select
Selection.Copy
Workbooks(Blatt).Activate
Sheets("Wartungsplan").Select
Cells.Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-27
Range("A2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("A2:A8"), Type:=xlFillDefault
Range("A2:A8").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("B2:C2"), Type:=xlFillDefault
Range("B2:C2").Select
Selection.AutoFill Destination:=Range("B2:C8"), Type:=xlFillDefault
Range("B2:C8").Select
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:D6"), Type:=xlFillDefault
Range("C6:D6").Select
Selection.AutoFill Destination:=Range("C6:D8"), Type:=xlFillDefault
Range("C6:D8").Select
Range("D2:G2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Range("D2:G2").Select
Selection.AutoFill Destination:=Range("D2:G5"), Type:=xlFillDefault
Range("D2:G5").Select
Range("D5:G5").Select
Selection.NumberFormat = "m/d/yyyy"
Range("E30").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!R6C1>"" "",""x"","" "")"
Range("B30:D30").Select
ActiveCell.FormulaR1C1 = _
"=IF(Kopf!R6C1>"" "",""Überprüfung der Sicherheitsschalter am Roboter"","" "")"
Range("D6").Select
Windows("Vorlage_SGM11.xlsm").Activate
Sheets("Kontrollkarte 1. Quartal").Select
Cells.Select
Selection.Copy
Workbooks(Blatt).Activate
Sheets("Kontrollkarte 1. Quartal").Select
Cells.Select
ActiveSheet.Paste
Range("A2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("A2:A8"), Type:=xlFillDefault
Range("A2:A8").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("B2:C2"), Type:=xlFillDefault
Range("B2:C2").Select
Selection.AutoFill Destination:=Range("B2:C8"), Type:=xlFillDefault
Range("B2:C8").Select
Range("C2").Select
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:D6"), Type:=xlFillDefault
Range("C6:D6").Select
Selection.AutoFill Destination:=Range("C6:D8"), Type:=xlFillDefault
Range("C6:D8").Select
Range("D2:G2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("D2:G5"), Type:=xlFillDefault
Range("D2:G5").Select
Range("D5:G5").Select
Selection.NumberFormat = "m/d/yyyy"
Range("E30").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!R6C1>"" "",""x"","" "")"
Range("B30:D30").Select
ActiveCell.FormulaR1C1 = _
"=IF(Kopf!R6C1>"" "",""Überprüfung der Sicherheitsschalter am Roboter"","" "")"
Windows("Vorlage_SGM11.xlsm").Activate
Range("A1:G1").Select
Sheets("Kontrollkarte 2. Quartal").Select
Cells.Select
Selection.Copy
Workbooks(Blatt).Activate
Sheets("Kontrollkarte 2. Quartal").Select
Cells.Select
ActiveSheet.Paste
Range("A2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("A2:A8"), Type:=xlFillDefault
Range("A2:A8").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("B2:C2"), Type:=xlFillDefault
Range("B2:C2").Select
Selection.AutoFill Destination:=Range("B2:C8"), Type:=xlFillDefault
Range("B2:C8").Select
Range("C2").Select
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:D6"), Type:=xlFillDefault
Range("C6:D6").Select
Selection.AutoFill Destination:=Range("C6:D8"), Type:=xlFillDefault
Range("C6:D8").Select
Range("D2:G2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("D2:G5"), Type:=xlFillDefault
Range("D2:G5").Select
Range("D5:G5").Select
Selection.NumberFormat = "m/d/yyyy"
Range("E30").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!R6C1>"" "",""x"","" "")"
Range("B30:D30").Select
ActiveCell.FormulaR1C1 = _
"=IF(Kopf!R6C1>"" "",""Überprüfung der Sicherheitsschalter am Roboter"","" "")"
Windows("Vorlage_SGM11.xlsm").Activate
Range("A1:G1").Select
Sheets("Kontrollkarte 3. Quartal").Select
Cells.Select
Selection.Copy
Workbooks(Blatt).Activate
Sheets("Kontrollkarte 3. Quartal").Select
Cells.Select
ActiveSheet.Paste
Range("A2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("A2:A8"), Type:=xlFillDefault
Range("A2:A8").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("B2:C2"), Type:=xlFillDefault
Range("B2:C2").Select
Selection.AutoFill Destination:=Range("B2:C8"), Type:=xlFillDefault
Range("B2:C8").Select
Range("C2").Select
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:D6"), Type:=xlFillDefault
Range("C6:D6").Select
Selection.AutoFill Destination:=Range("C6:D8"), Type:=xlFillDefault
Range("C6:D8").Select
Range("D2:G2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("D2:G5"), Type:=xlFillDefault
Range("D2:G5").Select
Range("D5:G5").Select
Selection.NumberFormat = "m/d/yyyy"
Range("E30").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!R6C1>"" "",""x"","" "")"
Range("B30:D30").Select
ActiveCell.FormulaR1C1 = _
"=IF(Kopf!R6C1>"" "",""Überprüfung der Sicherheitsschalter am Roboter"","" "")"
Windows("Vorlage_SGM11.xlsm").Activate
Range("A1:G1").Select
Sheets("Kontrollkarte 4. Quartal").Select
Cells.Select
Selection.Copy
Workbooks(Blatt).Activate
Sheets("Kontrollkarte 4. Quartal").Select
Cells.Select
ActiveSheet.Paste
Range("A2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("A2:A8"), Type:=xlFillDefault
Range("A2:A8").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("B2:C2"), Type:=xlFillDefault
Range("B2:C2").Select
Selection.AutoFill Destination:=Range("B2:C8"), Type:=xlFillDefault
Range("B2:C8").Select
Range("C2").Select
Range("C6").Select
Selection.AutoFill Destination:=Range("C6:D6"), Type:=xlFillDefault
Range("C6:D6").Select
Selection.AutoFill Destination:=Range("C6:D8"), Type:=xlFillDefault
Range("C6:D8").Select
Range("D2:G2").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!RC>0,Kopf!RC,"""")"
Selection.AutoFill Destination:=Range("D2:G5"), Type:=xlFillDefault
Range("D2:G5").Select
Range("D5:G5").Select
Selection.NumberFormat = "m/d/yyyy"
Range("E30").Select
ActiveCell.FormulaR1C1 = "=IF(Kopf!R6C1>"" "",""x"","" "")"
Range("B30:D30").Select
ActiveCell.FormulaR1C1 = _
"=IF(Kopf!R6C1>"" "",""Überprüfung der Sicherheitsschalter am Roboter"","" "")"
With ActiveWorkbook
.Save
.Close
End With
Next
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
mfg
Michael
:98:
WIN 10 Office 2019
Michael
:98:
WIN 10 Office 2019