ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   COPY MULTIPLE ROWS INSERTED BELOW EACH (https://www.excelbanter.com/excel-discussion-misc-queries/214193-copy-multiple-rows-inserted-below-each.html)

Justaddcat

COPY MULTIPLE ROWS INSERTED BELOW EACH
 
How can I copy all selected rows to insert each directly below without
individually copying then inserted each row one at a time?
Essentally I need ROW 1, 1, 2, 2, 3, 3, 4, 4, etc.? (I know the rows will
be in numerical order)
Thanks.

Sirirat

COPY MULTIPLE ROWS INSERTED BELOW EACH
 
You can select all those cells and COPY
then select any cell you want to copy to
and select PASTE | PASTE SPECIAL from the menu
In the paste special dialog, check 'Transpose', then <ok

Shoud be good to go :-)

"Justaddcat" wrote:

How can I copy all selected rows to insert each directly below without
individually copying then inserted each row one at a time?
Essentally I need ROW 1, 1, 2, 2, 3, 3, 4, 4, etc.? (I know the rows will
be in numerical order)
Thanks.


Sheeloo[_3_]

COPY MULTIPLE ROWS INSERTED BELOW EACH
 
Try the macro
(to run open the worksheet you want it to run on, press Alt-F11, choose
Insert-Module, paste the code below, press F5)
Sub insertrows()
Dim i, lastRow As Long

Application.ScreenUpdating = False

lastRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row
Rows(lastRow + 1).Select
For i = lastRow To 1 Step -1
ActiveCell.EntireRow.Insert
ActiveCell.Offset(-1, 0).EntireRow.Copy Destination:=ActiveCell
Rows(i).Select
Next

Application.ScreenUpdating = True
End Sub

"Justaddcat" wrote:

How can I copy all selected rows to insert each directly below without
individually copying then inserted each row one at a time?
Essentally I need ROW 1, 1, 2, 2, 3, 3, 4, 4, etc.? (I know the rows will
be in numerical order)
Thanks.


Justaddcat

COPY MULTIPLE ROWS INSERTED BELOW EACH
 
Thankyou, this works very well to copy down every row, which will be helful
some somes. Is there a way to do this but only copy down selected rows? and
in multiple selections?
eg. 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9...
Thankyou again.

"Sheeloo" wrote:

Try the macro
(to run open the worksheet you want it to run on, press Alt-F11, choose
Insert-Module, paste the code below, press F5)
Sub insertrows()
Dim i, lastRow As Long

Application.ScreenUpdating = False

lastRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row
Rows(lastRow + 1).Select
For i = lastRow To 1 Step -1
ActiveCell.EntireRow.Insert
ActiveCell.Offset(-1, 0).EntireRow.Copy Destination:=ActiveCell
Rows(i).Select
Next

Application.ScreenUpdating = True
End Sub

"Justaddcat" wrote:

How can I copy all selected rows to insert each directly below without
individually copying then inserted each row one at a time?
Essentally I need ROW 1, 1, 2, 2, 3, 3, 4, 4, etc.? (I know the rows will
be in numerical order)
Thanks.


Sheeloo[_3_]

COPY MULTIPLE ROWS INSERTED BELOW EACH
 
For this to work on selection

replace the line
lastRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row

with
lastRow = Selection.Rows.Count

Someone may help you with the code for multiple selection

"Justaddcat" wrote:

Thankyou, this works very well to copy down every row, which will be helful
some somes. Is there a way to do this but only copy down selected rows? and
in multiple selections?
eg. 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9...
Thankyou again.

"Sheeloo" wrote:

Try the macro
(to run open the worksheet you want it to run on, press Alt-F11, choose
Insert-Module, paste the code below, press F5)
Sub insertrows()
Dim i, lastRow As Long

Application.ScreenUpdating = False

lastRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row
Rows(lastRow + 1).Select
For i = lastRow To 1 Step -1
ActiveCell.EntireRow.Insert
ActiveCell.Offset(-1, 0).EntireRow.Copy Destination:=ActiveCell
Rows(i).Select
Next

Application.ScreenUpdating = True
End Sub

"Justaddcat" wrote:

How can I copy all selected rows to insert each directly below without
individually copying then inserted each row one at a time?
Essentally I need ROW 1, 1, 2, 2, 3, 3, 4, 4, etc.? (I know the rows will
be in numerical order)
Thanks.


Justaddcat

COPY MULTIPLE ROWS INSERTED BELOW EACH
 
Thankyou, hopefully someone can also help with the multiple selections.

"Sheeloo" wrote:

For this to work on selection

replace the line
lastRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row

with
lastRow = Selection.Rows.Count

Someone may help you with the code for multiple selection

"Justaddcat" wrote:

Thankyou, this works very well to copy down every row, which will be helful
some somes. Is there a way to do this but only copy down selected rows? and
in multiple selections?
eg. 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9...
Thankyou again.

"Sheeloo" wrote:

Try the macro
(to run open the worksheet you want it to run on, press Alt-F11, choose
Insert-Module, paste the code below, press F5)
Sub insertrows()
Dim i, lastRow As Long

Application.ScreenUpdating = False

lastRow = ActiveSheet.Cells(65536, "A").End(xlUp).Row
Rows(lastRow + 1).Select
For i = lastRow To 1 Step -1
ActiveCell.EntireRow.Insert
ActiveCell.Offset(-1, 0).EntireRow.Copy Destination:=ActiveCell
Rows(i).Select
Next

Application.ScreenUpdating = True
End Sub

"Justaddcat" wrote:

How can I copy all selected rows to insert each directly below without
individually copying then inserted each row one at a time?
Essentally I need ROW 1, 1, 2, 2, 3, 3, 4, 4, etc.? (I know the rows will
be in numerical order)
Thanks.



All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com