How to automatically insert a copied row after a specific value in a cell with VBA

How to automatically insert a copied row after a specific value in a cell with VBA

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.

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

_

CURRENT TABLE:

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

_

DESIRED TABLE

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


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

To VBA and beyond - building a RESTful backend using plain Microsoft Excel macros

When my coworkers and I discussed backend technologies for an upcoming project, someone jokingly mentioned Excel as people widely misused it as a terrible database replacement. Although we settled for .NET, the idea of using Excel as a backend fascinated me. Since I just recently finished my bachelor's thesis and had some spare time, I thought I'd give it a shot and see how far I'd get.

Excel VBA – Material Color Palette

![VBAMaterial-Color-Palette-BG](https://i.ibb.co/DwbX8NL/VBAMaterial-Color-Palette-BG.png "VBAMaterial-Color-Palette-BG") Hello there, this article is about how to get Material Color Palette [https://material.io/guidelines/style/color.html#] into...

Dynamically Select Cells For Use in a VBA Function

I've written the function below that I would like to use dynamically in my excel sheet where the function would assess the value of the variable selected in the formula and based on that value, perform a simple calculation referencing values in cells in different columns but in the same row.