[英]copy the same row from multiple sheets into one sheet in excel
I need to copy the same row from multiple sheets into one row. 我需要将同一行从多张纸复制到一行。
Example: I have an excel file with 5 sheets. 示例:我有一个5张excel文件。 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.
我必须按工作表的顺序复制第6张工作表中每张工作表的第10行(或第15行或第21行)。
Thanks in advance. 提前致谢。
Here is a sample for 6 sheets and rows # 7 : 这是6页和第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 6 th sheet. 行#7从第一5张将被复制到第 6 个片材。
This code will copy 7th row from all first 5 sheets into 6th sheet. 此代码会将所有前5张纸中的 第 7行复制到第6页中。
Sub row_copy()
For i = 1 To Worksheets.Count - 1
Sheets(i).Rows(7).Copy Sheets(6).Cells(i, 1)
Next i
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.