Dim
vb
As
Variant
Dim
matrix
As
Variant
Dim
lastRowVB
As
Variant
Dim
oRange
As
Range
Dim
iColumns
As
Integer
lastRow = ActiveSheet.UsedRange.Rows.Count
For
i = 1
To
lastRow
If
Cells(i, 345).Value =
"1"
Then
Dim
startJahr
As
Variant
Dim
offsetCell
As
Variant
startJahr = Year(Cells(i, 21))
Select
Case
startJahr
Case
2016
offsetCell = 0
Case
2017
offsetCell = 64
Case
2018
offsetCell = 128
Case
2019
offsetCell = 192
Case
2020
offsetCell = 256
End
Select
vb = Cells(i, 347)
matrix =
"Matrix_"
& vb
Set
oRange = Worksheets(
CStr
(startJahr)).Range(matrix)
iColumns = oRange.Columns.Count
Set
oRange = Range(oRange.Cells(2, 1), oRange.Cells(2, iColumns))
oRange.Insert Shift:=xlDown
Range(matrix).Cells(2, 2) = Cells(i, 3)
Range(matrix).Cells(2, 3) = Cells(i, 4)
Range(matrix).Cells(2, 4) = Cells(i, 5)
Range(matrix).Cells(2, 5) = Cells(i, 6)
Range(matrix).Cells(2, 6) = Cells(i, 7)
Range(matrix).Cells(2, 7) = Cells(i, 8)
Range(matrix).Cells(2, 8) = Cells(i, 9)
Range(matrix).Cells(2, 9) = Cells(i, 10)
Range(matrix).Cells(2, 10) = Cells(i, 11)
Range(matrix).Cells(2, 11) = Cells(i, 12)
Range(matrix).Cells(2, 12) = Cells(i, 12)
Range(matrix).Cells(2, 13) = Cells(i, 14)
Range(matrix).Cells(2, 12) = Cells(i, 15)
Range(matrix).Cells(2, 13) = Cells(i, 16)
Range(matrix).Cells(2, 14) = Cells(i, 17)
Range(matrix).Cells(2, 15) = Cells(i, 18)