ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Duplicate Rows Based On Cell Value? (https://www.excelbanter.com/excel-programming/412849-duplicate-rows-based-cell-value.html)

[email protected]

Duplicate Rows Based On Cell Value?
 
Hi,

I´m lookig for:
Pos. Qty W H
1 2 316 910
2 4 399 1180
3 1 784 1180

to become:
Pos. Qty W H
1 2 316 910
1 2 316 910
2 4 399 1180
2 4 399 1180
2 4 399 1180
2 4 399 1180
3 1 784 1180

Thanks!

Bob Phillips[_3_]

Duplicate Rows Based On Cell Value?
 
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = LastRow To 2 Step -1

If .Cells(i, "B").Value 1 Then

.Rows(i + 1).Resize(.Cells(i, "B").Value - 1).Insert
.Rows(i).Copy .Cells(i + 1, "A").Resize(.Cells(i,
"B").Value - 1)
End If
Next i

End With

End Sub

--
__________________________________
HTH

Bob

wrote in message
...
Hi,

I´m lookig for:
Pos. Qty W H
1 2 316 910
2 4 399 1180
3 1 784 1180

to become:
Pos. Qty W H
1 2 316 910
1 2 316 910
2 4 399 1180
2 4 399 1180
2 4 399 1180
2 4 399 1180
3 1 784 1180

Thanks!



[email protected]

Duplicate Rows Based On Cell Value?
 
Great!

Thank You, Bob!

This piece made my life much easier!

RV


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com