Public Declare Function timeGetTime Lib "winmm.dll" () As Long
Const colbound As Long = 3
Const rowbound As Long = 30000
Dim dat(1 To rowbound, 1 To colbound) As Long
Private Sub Command1_Click()
Dim ts As Long, t0 As Long
Dim i As Long, j As Long
Dim xlsapp As New Excel.Application
Dim xls As Excel.Workbook
Dim sheet As Excel.Worksheet
Set xls = xlsapp.Workbooks.Add
Set sheet = xls.Worksheets(1)
ts = timeGetTime()
For i = 1 To rowbound
For j = 1 To colbound
dat(i, j) = i * j
Next
Next
sheet.Range(sheet.Cells(1, 1), sheet.Cells(rowbound, colbound)) = dat
t0 = timeGetTime() - ts
'编译成EXE后,像这样进行3万行的共10万个赋值只需要 300 毫秒。