You are very welcome.
Cut-Paste specified number of rows from different sheets into one sheet
- Hyperventilate
- Thread is marked as Resolved.
-
-
-
Mumps, been using this macro splendidly. Just need another small addition please. Currently I need to execute the 'cut rows' macro manually for the number of times I want it to work. Could we do it in a way where I specify the number of times I want it to loop? Sometimes I want it to go 20 times and doing that manually is a pain. Attaching my file just for reference.
-
I'm not sure what you mean. The 'CutRows' macro loops once through all the sheets referenced in column A of Sheet1. Are you saying that you want to loop through all those sheets more than once? Please explain in detail what you are trying to accomplish.
-
I'm not sure what you mean. The 'CutRows' macro loops once through all the sheets referenced in column A of Sheet1. Are you saying that you want to loop through all those sheets more than once? Please explain in detail what you are trying to accomplish.
Yes, you are right. I want it to loop through all those sheets more than once. I'm creating sets of data in a particular sequence, one loop is one set and so on. Sometimes I need 20 sets, so I run the macro 20 times, was wondering if it can be done in the code itself (though the number of sets varies each time).
-
Try:
Code
Display MoreSub CutRows() Application.ScreenUpdating = False Dim ws As Worksheet, desWS As Worksheet, sh As Range, response As String, x As Long Set desWS = Sheets("Sheet2") response = InputBox("Enter the number of sets to create.") If response = "" Then Exit Sub For x = 1 To response For Each sh In Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp)) Sheets(sh.Value).Rows("2:" & sh.Offset(, 1).Value + 1).Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1) Sheets(sh.Value).Rows("2:" & sh.Offset(, 1).Value + 1).Delete Next sh Next x Application.ScreenUpdating = True End Sub
-
-
Works perfect as always, thanks a ton!
-
You are very welcome.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!