I have a table that contains a set of bundles that have to be broken down into their components. For this I'm looking for VBA instructions that will copy any row that contains the tag "-edubnd" at the end of the 'sku' cell (please see table bellow for example) twice underneath itself.
It might be easier to ignore the tag component and use a specific set of values that the code looks for, that's also possible as the values marked as bundles are always the same in the column. What I mean is, instead of looking for the -edubnd tag, the code just looks for a specific value in that column,
I have created a sample table below that is similar-enough to my table in excel that it should serve to illustrate the question.
I'm currently filtering out the dataset, copying it into a different excel document, then running this:
Sub insertrows()
Dim I As Long
Dim xCount As Integer
LableNumber:
xCount = 2
For I = Range("A" & Rows.CountLarge).End(xlUp).Row To 1 Step -1
Rows(I).Copy
Rows(I).Resize(xCount).Insert
Next
Application.CutCopyMode = False
End Sub
_
column1 | column2 | column3 | column3 ---------------------------------------------- A | pear | blue | 10 A | apple | orange | 50 A | orange | yellow | 30 A | kiwi | yellow | 20 A | orange-edubnd | blue | 100 A | apple | green | 10 A | pear-edubnd | green | 50 A | mango | pink | 60
_
Note: the copied row after each distinct column2 with the -edubnd tag
column1 | column2 | column3 | column3 ---------------------------------------------- A | pear | blue | 10 A | apple | orange | 50 A | orange | yellow | 30 A | kiwi | yellow | 20 A | orange-edubnd | blue | 100 A | orange-edubnd | blue | 100 A | orange-edubnd | blue | 100 A | apple | green | 10 A | pear-edubnd | green | 50 A | pear-edubnd | green | 50 A | pear-edubnd | green | 50 A | mango | pink | 60
#excel-vba #excel