AW: Musterdateien und Datenschutz...
29.03.2013 13:20:23
{Boris}
Hi Peter,
hier ist ein Code, der das erledigt. Der Monat wird aber STATISCH eingetragen, da ich nicht weiß, wie Dein kompletter Tabellenaufbau mit allen Monaten aussieht (und wo man dann den Monat auslesen könnte).
Es wird auch nicht auf Doppelungen geachtet. Außerdem wird erstmal pauschal Zeile 3 bis 10 abgearbeitet - das musst Du dann natürlich auch noch auf Deinen echten Bedarf anpassen.
Aber teste selbst.
Option Explicit
Sub til()
Dim x As Long, y As Long, var As Variant, sTemp As String, lRow As Long
For y = 3 To 10
For x = 1 To 31
If Tabelle2.Cells(y, x + 1).MergeCells Then
If Tabelle2.Cells(y, x + 1).MergeArea(1).Address sTemp Then
With Tabelle1
var = Split(Tabelle2.Cells(y, x + 1), "/")
lRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(lRow, 1) = y
.Cells(lRow, 2) = var(0)
.Cells(lRow, 3) = Tabelle2.Cells(y, 1)
.Cells(lRow, 4) = var(1)
.Cells(lRow, 5) = var(2)
.Cells(lRow, 6) = var(3)
.Cells(lRow, 7) = x
.Cells(lRow, 8) = x + Tabelle2.Cells(y, x + 1).MergeArea.Count - 1
.Cells(lRow, 9) = Tabelle2.Cells(1, 2)
.Cells(lRow, 10) = var(4)
End With
sTemp = Tabelle2.Cells(y, x + 1).Address
End If
End If
Next x
Next y
End Sub
VG, Boris