Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 将部分行移到第二行,将部分行移到第三行_Excel_Vba - Fatal编程技术网

Excel 将部分行移到第二行,将部分行移到第三行

Excel 将部分行移到第二行,将部分行移到第三行,excel,vba,Excel,Vba,我有一个问题,我不知道是否有出路。我有一个大的电子表格(8000行),我需要处理,数据被放入额外的列中,而它本应该被放入第二行和第三行。每个条目跨越一个大行,而不是应该跨越的3个小行。现在我需要在每一行之后创建两个新行。然后获取C-F列中的数据,并将其移动到下一行(A-D列)。然后取G-H列,并将其移动到系列中的第三行(A-B列) 例如: 原始数据: A1 A2 A3 A4 A5 A6 A7 A8 B1 B2 B3 B4 B5 B6 B7 B8 结果数据:

我有一个问题,我不知道是否有出路。我有一个大的电子表格(8000行),我需要处理,数据被放入额外的列中,而它本应该被放入第二行和第三行。每个条目跨越一个大行,而不是应该跨越的3个小行。现在我需要在每一行之后创建两个新行。然后获取C-F列中的数据,并将其移动到下一行(A-D列)。然后取G-H列,并将其移动到系列中的第三行(A-B列)

例如:

原始数据:

A1  A2  A3  A4  A5  A6  A7  A8  
B1  B2  B3  B4  B5  B6  B7  B8  
结果数据:

A1  A2  
A3  A4  A5  A6  
A7  A8

B1  B2  
B3  B4  B5  B6  
B7  B8
以此类推,直到8000行变为24000(或32000)行。有人帮我吗


谢谢

你可以用这个。不过,这可能需要一点时间才能完成。它循环8000行,每行数据插入2行,并将原始数据复制到适当的行:

Sub main()
Dim i As Integer
Dim intRow As Integer
intRow = 2
Application.ScreenUpdating = False
For i = 1 To 8000
    Rows(intRow).Insert
    Cells(intRow, 1) = Cells(intRow - 1, 3)
    Cells(intRow, 2) = Cells(intRow - 1, 4)
    Cells(intRow, 3) = Cells(intRow - 1, 5)
    Cells(intRow, 4) = Cells(intRow - 1, 6)
    Cells(intRow - 1, 3) = ""
    Cells(intRow - 1, 4) = ""
    Cells(intRow - 1, 5) = ""
    Cells(intRow - 1, 6) = ""
    intRow = intRow + 1
    Rows(intRow).Insert
    Cells(intRow, 1) = Cells(intRow - 2, 7)
    Cells(intRow, 2) = Cells(intRow - 2, 8)
    Cells(intRow - 2, 7) = ""
    Cells(intRow - 2, 8) = ""
    intRow = intRow + 2
Next i
Application.ScreenUpdating = True
End Sub