Gruppe
Allgemein
Problem
In der Spalte "Anzahl" (D) sollen unterhalb der Zellen, in denen der Wert > 0 ist, soviel Zeilen eingefügt werden, wie der Wert beträgt. Unmittelbar unter dem Wert ist eine Null einzufügen.
StandardModule: basMain
Sub Einfuegen()
Dim rng As Range
Dim iRow As Integer
With Range("Anzahl")
Set rng = .Cells(Rows.Count, 1).End(xlUp)
iRow = 1
Do Until iRow > rng.Row
If WorksheetFunction.IsText(.Cells(iRow)) = False Then
If Not IsEmpty(.Cells(iRow)) Then
If .Cells(iRow).Value > 0 Then
iRow = iRow + 1
Rows(iRow & ":" & _
iRow + .Cells(iRow - 1).Value - 1).Insert
.Cells(iRow) = 0
iRow = iRow + .Cells(iRow - 1).Value - 1
End If
End If
End If
iRow = iRow + 1
Loop
End With
End Sub