在excel中每n行复制一次

在excel中每n行复制一次,excel,optimization,excel-formula,excel-2003,vba,Excel,Optimization,Excel Formula,Excel 2003,Vba,例如,如果我有30行,我想复制第一行、第二行和第三行,跳过五行,然后复制下三行,再跳过五行,然后复制下三行:我该怎么做?到目前为止,我只有这个公式 =OFFSET(Sheet1!$A$1,(ROW()-1)*5,0) 这只会给我一个单元格值,但我希望将整行复制到另一个工作表中 任何帮助都会很好!谢谢这里有一个提示: Here is a hint: Row Number Modulus 8 in (1,2,3) identifies the target Row Numbers. Ente

例如,如果我有30行,我想复制第一行、第二行和第三行,跳过五行,然后复制下三行,再跳过五行,然后复制下三行:我该怎么做?到目前为止,我只有这个公式

=OFFSET(Sheet1!$A$1,(ROW()-1)*5,0)
这只会给我一个单元格值,但我希望将整行复制到另一个工作表中

任何帮助都会很好!谢谢

这里有一个提示:
Here is a hint: 
Row Number Modulus 8 in (1,2,3) identifies the target Row Numbers.


Enter in first column, first row and copy down for each column:
=IF(AND(MOD(ROW(Sheet1!A1),8) > 0,MOD(ROW(Sheet1!A1),8) < 4),Sheet1!A1,"")
(1,2,3)中的行号模数8标识目标行号。 在第一列、第一行中输入,并为每列向下复制: =如果(和(第1排第1!A1页,第8页)>0,第1排第1!A1页,第8页)<4,第1!A1页,“”)
这样就可以了。只需将单元格(行、列)用于循环即可

Sub Copy3Skip5()

Dim iRow As Integer
Dim count As Integer
Dim tRow As Integer
Dim lastRow As Integer
Dim source As String
Dim target As String

source = "Sheet1"
target = "Sheet2"
'Get the last row on your source sheet.
lastRow = Sheets(source).Range("A65536").End(xlUp).Row
'Set the Target Sheet first row
tRow = 2
'assuming your data starts on Row 2 after a header row.
'Loop through the Source sheet
For iRow = 2 To lastRow
    count = 1
    Do While count <= 3
        'Cells(tRow, 1) translates to Range("A2") if tRow = 2  and "A3" if tRow = 3. and so on
        Sheets(target).Cells(tRow, 1) = Sheets(source).Cells(iRow, 1)
        tRow = tRow + 1
        iRow = iRow + 1
        count = count + 1
    Loop
'add 4 to the iRow, because we already added 1 at the end of the previous loop
    iRow = iRow + 4
Next iRow

End Sub
子副本3skip5()
Dim iRow作为整数
将计数设置为整数
Dim tRow为整数
将最后一行设置为整数
将源设置为字符串
将目标变暗为字符串
source=“Sheet1”
target=“Sheet2”
'获取源工作表上的最后一行。
lastRow=图纸(来源)。范围(“A65536”)。结束(xlUp)。行
'将目标工作表设置为第一行
tRow=2
'假设数据从标题行之后的第2行开始。
'在源工作表中循环
对于iRow=2到最后一行
计数=1

Do While count抱歉,我没有指定,我愿意使用VBA或公式。我也在使用Excel2003。该公式被放入表2中并向下拖动。它每五次收集所需列中的值。不过我想把整行都抄过来。谢谢你的回答。我仍然想知道如何复制3行,跳过下一个第n行,复制3行,跳过下一个第n行,等等……他暗示说。将“=MOD(第(A1)行,第8)行)”放入工作表的单元格A1中并向下拖动,查看发生了什么。