将行从一个表复制到另一个表[重复]

时间:2022-09-15 22:40:43

This question already has an answer here:

这个问题在这里已有答案:

Suppose I have a table in excel containing 1000 rows and 10 columns. How can I copy every 7th row from this table to a new table whose first row will be this 7th row, second row will be that table 14th row and so on.

假设我在excel中有一个包含1000行和10列的表。如何将此表中的每第7行复制到新表中,其第一行将是此第7行,第二行将是该表第14行,依此类推。

I have never done these kind of things in excel before. How to do it?

我以前从未在excel中做过这些事情。怎么做?

2 个解决方案

#1


2  

If you want to stick with plain Excel (no VBA). Add two columns at the end of your table. The first being a count of the line, the second flagging if the line count is divisible by 7 - I used the formula =IF(MOD(D4,7)=0,"Divisible by 7", "-").

如果你想坚持使用普通的Excel(没有VBA)。在表的末尾添加两列。第一个是行的计数,第二个标记行计数是否可被7整除 - 我使用公式= IF(MOD(D4,7)= 0,“可被7整除”,“ - ”)。

将行从一个表复制到另一个表[重复]

Then filter the table on the 'Mark every 7th item' column, and copy and paste to new table.

然后在“标记每7个项目”列上过滤表格,然后复制并粘贴到新表格。

#2


1  

You need a macro. Press alt + F11

你需要一个宏。按alt + F11

Basically you run that macro that goes like this

基本上你运行像这样的宏

sub Copyer()
dim I as integer
Dim K as integer
I = 7
K = 1
while (Activesheet.Range("A" & I ).Value <> "")
 DestinationSheet.Range("A" & K ).Value = Activesheet.Range("A" & I).Value
K = K + 1
I = I + 7
Loop
End Sub

Code may need some grooming but that's the idea

代码可能需要一些修饰,但这是主意

#1


2  

If you want to stick with plain Excel (no VBA). Add two columns at the end of your table. The first being a count of the line, the second flagging if the line count is divisible by 7 - I used the formula =IF(MOD(D4,7)=0,"Divisible by 7", "-").

如果你想坚持使用普通的Excel(没有VBA)。在表的末尾添加两列。第一个是行的计数,第二个标记行计数是否可被7整除 - 我使用公式= IF(MOD(D4,7)= 0,“可被7整除”,“ - ”)。

将行从一个表复制到另一个表[重复]

Then filter the table on the 'Mark every 7th item' column, and copy and paste to new table.

然后在“标记每7个项目”列上过滤表格,然后复制并粘贴到新表格。

#2


1  

You need a macro. Press alt + F11

你需要一个宏。按alt + F11

Basically you run that macro that goes like this

基本上你运行像这样的宏

sub Copyer()
dim I as integer
Dim K as integer
I = 7
K = 1
while (Activesheet.Range("A" & I ).Value <> "")
 DestinationSheet.Range("A" & K ).Value = Activesheet.Range("A" & I).Value
K = K + 1
I = I + 7
Loop
End Sub

Code may need some grooming but that's the idea

代码可能需要一些修饰,但这是主意