How do I duplicate lines based on a cell value

BazzaM

New Member
Joined
Nov 1, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am looking for some help in automating a copy on paste of a list of values, Repeating a specific line a number of times before moving to the next line.

An example of the input data would be

ABCDEFGHIJ
MaterialPlantSlocDeliv.QtyUnPicked QtyUn2Gross WeightDescriptionLabels Required
Material 1
6200​
620​
2​
PC
2​
KG
18​
Description 1
2​
Material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 2
8​
Material 3
6200​
620​
8​
PC
8​
KG
1.84​
Description 3
4​

From this data, I would like to copy this data to a new sheet, I would like the lines repeating in the new sheet based on the value in "Labels Required" without the output looking like the below.

ABCDEFGHIJ
MaterialPlantSlocDeliv.QtyUnPicked QtyUn2Gross WeightDescriptionLabels Required
Material 1
6200​
620​
2​
PC
2​
KG
18​
Description 11 of 2
Material 1
6200​
620​
2​
PC
2​
KG
18​
Description 12 of 2
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 21 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 22 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 23 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 24 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 25 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 26 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 27 of 8
material 2
6200​
620​
8​
PC
8​
KG
14.4​
Description 28 of 8
Material 3
6200​
620​
8​
PC
8​
KG
1.84​
Description 31 of 4
Material 3
6200​
620​
8​
PC
8​
KG
1.84​
Description 32 of 4
Material 3
6200​
620​
8​
PC
8​
KG
1.84​
Description 33 of 4
Material 3
6200​
620​
8​
PC
8​
KG
1.84​
Description 34 of 4

I would assume the VBA would be best suited to handle this, but I have no grasp of it to be able to come close to what I want it to accomplish.

Column references would never change with the data, though it could be created as a table if that's easier.

Any help would be appreciated.

Cheers,
 
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top