我目前正试图创建一个列表,从两个单独的工作表,所有可能的条目组合,但每当我尝试运行它,大约20秒后Excel崩溃。有没有人有任何提示如何更有效地做到这一点,或一种方法来使这项工作?谢谢!VBA嵌套for循环崩溃Excel
Sub Create()
Dim dates, groups, current As Integer
Dim dateValue As Date
Dim groupValue As String
Dim cell As Long
Application.ScreenUpdating = False
Sheets(3).Cells.Clear
cell = 1
For dates = 1 To 730
Sheets(1).Select
dateValue = Cells(dates, 1).Value
For groups = 1 To 155
Application.StatusBar = dateValue & " " & groupValue
Sheets(2).Select
groupValue = Cells(groups, 1).Value
Sheets(3).Select
Cells(cell, 1) = dateValue
Cells(cell, 2) = groupValue
cell = cell + 1
Next groups
Next dates
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
如果一个答案解决了你的问题,你可以点击复选标记来帮助奖励那些帮助你的人:) – bmende