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.
Corder
Mar 28, 2022Copper Contributor
Amazing! Would this still work when trying to have the results appear on a separate sheet? I'm still new to VBA in Excel; is this SharePoint compatible? The document this is on is shared Teams Group and needs to be accessible for everyone.
OliverScheurich
Mar 28, 2022Gold Contributor
The results can appear on a different sheet. Click the button in cell G2 in the attached file and check the results in sheet "Tabelle2". I don't work with Sharepoint and can't answer this question unfortunately.
- CorderMar 29, 2022Copper ContributorNo worries,
I appreciate the help greatly!- MCasey3071Nov 22, 2024Copper Contributor
Just seen this as I was stuck, I found a a great Software named EasyDataTransform which makes this so simple