Forum Discussion
Corder
Mar 28, 2022Copper Contributor
Formula to Duplicate Entire Rows Based on Cell Value
Hello everyone! I'm trying to create a formula that will duplicate an entire row based on a cell's value. Below is a mock photo of what I am hoping to accomplish: The formula would g...
- Mar 28, 2022
Sub companyemployees() Dim i As Double Dim j As Double Dim z As Double Dim w As Double For i = 2 To 1000 j = Cells(i, 2).Value For z = 2 To j + 1 Cells(z + w, 4).Value = Cells(i, 1).Value Cells(z + w, 5).Value = Cells(i, 2).Value Next z w = w + z - 2 Next i End Sub
Maybe with these lines of VBA code. Click the button in cell G2 in the attached file to start the macro.
Starrysky1988
Mar 28, 2022Iron Contributor
If you are using beta version, you may write the formula as below with 1 helper formula behind.
Corder
Mar 29, 2022Copper Contributor
Unfortunately, I don't have access to the beta since it is supplied by my company. I don't mind using a helper column since this sheet won't be seen anyway. Do you know of another formula or set of formulas that will accomplish the same thing using the non-beta version of Excel?