Dim i As Long Dim x As Long Dim y As Long Dim myArg(1 To 100, 1 To 100) As Long
For i = 1 To 1000 For x = 1 To 100 For y = 1 To 100 myArg(x, y) = i + x + y - 2 Next Next ' この表示(画面更新)が確実に毎回行われるようにしたい。 Worksheets("Sheet1").Range("A1:CV100") = myArg Next
Private Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Private Declare Function RedrawWindow Lib "user32" (ByVal hWnd As Long, ByVal lprcUpdate As Long, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Const RDW_INVALIDATE As Long = 1 'Invalidates the redraw area.
Const RDW_ALLCHILDREN As Long = 128 'Redraw operation includes child windows if present in the redraw area.
Const RDW_UPDATENOW As Long = 256 'Updates the specified redraw area immediately.
Sub ScreenUpdatingTest()
Dim i As Long
Dim hWnd As Long
hWnd = GetForegroundWindow()
For i = 1 To 10000
ActiveSheet.Range("A1") = i
Call RedrawWindow(hWnd, 0, 0, RDW_INVALIDATE + RDW_UPDATENOW + RDW_ALLCHILDREN)
Next
End Sub