I found a code that will take the following:
Column A | Column B
apples | 2
oranges | 3
and produce:
Column A | Column B
apples | 2
apples | 2
oranges | 3
oranges | 3
oranges | 3
How can i modify the code to do that with columns A:Z instead of just two columns?
I can move the multiplier to any column i want if that will help.
Sub CopyData()
Dim lRow As Long
Dim RepeatFactor As Variant
lRow = 1
Do While (Cells(lRow, "A") <> "")
RepeatFactor = Cells(lRow, "B")
If ((RepeatFactor > 1) And IsNumeric(RepeatFactor)) Then
Range(Cells(lRow, "A"), Cells(lRow, "B")).Copy
Range(Cells(lRow + 1, "A"), Cells(lRow + RepeatFactor - 1, "B")).Select
Selection.Insert Shift:=xlDown
lRow = lRow + RepeatFactor - 1
End If
lRow = lRow + 1
Loop
End Sub
Bookmarks