2015-06-16 36 views
0
With ThisWorkbook.Worksheets("test") 
    Lastrow = .Cells(.Rows.count, 2).End(xlUp).Row 
     For i = LBound(sPrincipal) To (UBound(sPrincipal) - 3) 
       .Cells((Lastrow + 1), 1) = sPrincipal(i) 
       .Cells((Lastrow + 1), 2) = sInterest(i) 
       .Cells((Lastrow + 1), 3) = sBalance(i) 
        Lastrow = Lastrow + 1 
     Next i 
End With 

大约有10万行(列数多于此处显示的数量)需要定期填写,并且需要加快速度,因为这需要超过2-3小时。任何人都可以建议是否有办法加快这个过程。提前致谢。在VBA中提高时间

+1

什么是sprrinciple?范围?数组?变量?是其他变量是相同类型的吗? – Degustaf

+2

您的代码的慢位将与表单交互,将其全部读入数组,然后输出作为一个互动,你也可以使用screnupdating和计算,但是记得在 – 99moorem

+0

@Degustaf之后重新打开它们对不起,这些都是数组。 – Meesha

回答

2
dim entries as Integer 

entries = UBound(sPrinciple) - LBound(sPrinciple) 
With ThisWorkbook.Worksheets("test") 
    Lastrow = .Cells(.Rows.count, 2).End(xlUp).Row 
    .Cells((Lastrow + 1), 1).Resize(entries, 1).Value = _ 
     WorksheetFunction.Transpose(sPrinciple) 
    .Cells((Lastrow + 1), 2).Resize(entries, 1).Value = _ 
     WorksheetFunction.Transpose(sInterest) 
    .Cells((Lastrow + 1), 3).Resize(entries, 1).Value = _ 
     WorksheetFunction.Transpose(sBalance) 
End With 

这确实有,你只能在一个时间贴65536行的缺点(在Excel 2003中的行限制。我会建议分批在那里处理,在一时间许多行,直到完成运行代码整个数据集