copy the same row from multiple sheets into one sheet in excel

百般思念 提交于 2019-12-04 05:51:12

问题


I need to copy the same row from multiple sheets into one row.

Example: I have an excel file with 5 sheets. I have to copy the 10th row (or the 15th row, or the 21th row) of every sheet in a 6th sheet, in the order of the sheets.

Thanks in advance.


回答1:


This code will copy 7th row from all first 5 sheets into 6th sheet.

Sub row_copy()

For i = 1 To Worksheets.Count - 1

Sheets(i).Rows(7).Copy Sheets(6).Cells(i, 1)

Next i

End Sub



回答2:


Here is a sample for 6 sheets and rows # 7:

Sub copyrow()
    Dim Nrow As Long, Nsheet As Long
    Dim i As Long

    Nrow = 7
    Nsheet = 6

    For i = 1 To Nsheet - 1
        Sheets(i).Cells(Nrow, 1).EntireRow.Copy Sheets(Nsheet).Cells(i, 1)
    Next i
End Sub

The row # 7 from the first 5 sheets will be copied into the 6th sheet.



来源:https://stackoverflow.com/questions/37835442/copy-the-same-row-from-multiple-sheets-into-one-sheet-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!