我目前正試圖創建一個列表,從兩個單獨的工作表,所有可能的條目組合,但每當我嘗試運行它,大約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