2014-05-03 58 views
1

我有一个问题,我不知道是否有出路。我有一个需要操作的大型电子表格(8000行),其中数据被放入其他列中,而应该放入第二行和第三行。每个条目跨越一个大行而不是3个小行,因为它应该是。所以现在我需要在每个现有行之后创建两个新行。然后在C-F列中获取数据,并将其移至下一行(列A-D)。然后取出G-H列并将其移至该系列的第3行(列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)行。那里有任何帮助吗?

谢谢!

回答

2

您可以使用它。尽管这可能需要一点时间才能完成。它通过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 
相关问题