Dim row As Integer
Dim strRange As String
Selecting the Sheet
Sheets("Matrix").Select
Range("C3").Select
ActiveCell.FormulaR1C1 = _ "=SUMIF(Aufstellung!R13C2:R[997]C,Matrix!RC[-1],Aufstellung!R13C3:R[997]C)"
Range("C3").Select
row = Count() + 3 - 1
strRange = "C3:C" & row
Range(strRange).Select
Selection.AutoFill Destination:=Range(strRange), Type:=xlFillDefault
---> here comes the Runtimeerror 1004
: The AutoFill-method of the range object coudnt be run
strRange = "B3:D" & row
Range(strRange).Select
Selection.Copy
strRange = "F3:H" & row
Range(strRange).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Kassenblatt").Select
row = Count() + 6 - 1
strRange = "C6:F" & row
Range(strRange).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B6").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(RC[4]>0,R[-1]C+1,"""")"
Range("B6").Select
strRange = "B6:B" & row
---> here will probably come the same Runtimeerror 1004
: The AutoFill-method of the range object coudnt be run
Selection.AutoFill Destination:=Range(strRange), Type:=xlFillDefault
Range(strRange).Select
Range("A6").Select
ActiveCell.FormulaR1C1 = "=IF(RC[5]>0,R1C4,"""")"
Range("A6").Select
strRange = "A6:A" & row
---> here will probably come the same Runtimeerror 1004
: The AutoFill-method of the range object coudnt be run
Selection.AutoFill Destination:=Range(strRange), Type:=xlFillDefault
End Sub
Helper Function for counting all rows, that have a value - can be ignored for the question
Public Function Count() As Integer
Dim n As Integer
n = Worksheets("Formeln & Daten").Range("G21:G1000").Cells.SpecialCells(xlCellTypeConstants).Count
Count = n
End Function