Notifications
Clear all
VBA & Macros
3
Posts
2
Users
0
Reactions
58
Views
Topic starter
Hi,
Please can you help to Duplicate the rows based on count.
Example:
Input:
Industry | Duplication Count |
Semiconductors | 2 |
Computer Hardware | 3 |
Output:
Industry | Number |
Semiconductors | 1 |
Semiconductors | 2 |
Computer Hardware | 1 |
Computer Hardware | 2 |
Computer Hardware | 3 |
Please check attached file to get more sample.
Thanks;
Marsil
Posted : 30/12/2020 8:10 pm
Try this, outputs the detail to column M & N
Sub RepeatDown()
Dim R As Range
Dim C As Range
Dim Product As String
Dim NextRow As Integer
Dim ProductQty As Integer
Dim i As Integer
Set R = Range("A2:a7")
For Each C In R
NextRow = Cells(Rows.Count, 13).End(xlUp).Row
Product = C.Value
ProductQty = C.Offset(0, 1).Value
For i = 1 To ProductQty
With Range("m" & NextRow + i)
.Value = Product
.Offset(0, 1).Value = i
End With
Next i
Next C
End Sub
Posted : 31/12/2020 5:01 pm
Topic starter
Deep thanks Purfleet,
Thanks;
Marsil
Posted : 01/01/2021 5:23 am