AW: Array-Namen ändern
10.11.2017 16:49:21
Jens
Hallo,
der große Datensatz wird aus verschiedenen Tabellen-Blätten zusammengelesen (kommen aus unterschiedlichen Datenbanken, unterschiedlicher Teilunternehmen... --> lokale Bereichsfürsten mit IT-/Datenbanken-Eigengewächsen...)
Mein Code sieht im Moment wie folgt aus (vereinfacht und verkürzt auf 4 statt 96):
Sub splitten()
Dim i as Long
Dim j as Long
Dim Zeilen as Long
Dim Spalten as Long
Dim MatrixSektorPLZ01(1 to Zeilen, 1 to Spalten) as Variant
Dim MatrixSektorPLZ02(1 to Zeilen, 1 to Spalten) as Variant
Dim MatrixSektorPLZ03(1 to Zeilen, 1 to Spalten) as Variant
Dim MatrixSektorPLZ04(1 to Zeilen, 1 to Spalten) as Variant
Zeilen = 10000
Spalten = 11
Dim counter( 1 to 4) as long 'Zähler für Zeile Untermatrix PLZ_xy
For i = 1 to 4
Counter(i ) = 1
Next i
For i = 1 To Zeilen
If i = 1 Then 'Spaltenüberschrift übernehmen
For j = 1 to Spalten '11 Spalten
MatrixSektorPLZ01(1, j) = MatrixDatensatz(1, j)
MatrixSektorPLZ02 (1, j) = MatrixDatensatz (1, j)
MatrixSektorPLZ03 (1, j) = MatrixDatensatz (1, j)
MatrixSektorPLZ04 (1, j) = MatrixDatensatz (1, j)
Next j
Else
Select Case MatrixDatensatz(i, 4) 'Datensatz nach Spalte 4 (PLZ-Region) aufsplitten in _
Unterdatensätze
Case 01
For j = 1 To Spalten
MatrixSektorPLZ01(1 + counter(1), j) = MatrixDatensatz (i, j)
Next j
counter(1) = counter(1) + 1
Case 02
For j = 1 To Spalten
MatrixSektorPLZ02 (1 + counter(2), j) = MatrixDatensatz (i, j)
Next j
counter(2) = counter(2) + 1
Case 03
For j = 1 To Spalten
MatrixSektorPLZ03 (1+counter(3), j) = MatrixDatensatz (i, j)
Next j
counter(3) = counter(3) + 1
Case 04
For j = 1 To Spalten
MatrixSektorPLZ04(1 + counter(4), j) = MatrixDatensatz (i, j)
Next j
counter(4) = counter(4) + 1
End Select
End Sub