Dim R As Long, C As Integer, D As Long, ER As Long, EC As Long, MxC As Integer, IMax As Long
Dim SampDt(), FF As String
Dim TMP As Worksheet, RDB As Worksheet
Dim TmpS As String, RdbS As String
Sub Make_Samp_ER2()
'
' SampDat Macro
' マクロ作成日 : 2008/10/8 ユーザー名 : 寺田屋の龍馬
'
' 100万件のサンプルデータをシート1に作成
' Eco_RDB【エコ・RDB】 Ver.2.0
TmpS = "Sheet1": RdbS = "Sheet2"
Set TMP = Worksheets(TmpS) Set RDB = Worksheets(RdbS)
MsgBox "サンプルデータ作成スタート! "
TMP.Range("A1:AF60000").ClearContents
ST$ = Time$
IMax = RDB.Cells(3, 201) '対象レコード数
MxC = (IMax - 1) \ 60000 + 1: FF = String(16, Chr(-1))
SampDt() = TMP.Range(TMP.Cells(1, 1), TMP.Cells(60000, MxC)).Value D = 0
For C = 1 To MxC
For R = 1 To 60000
SampDt(R, C) = Int((1000000) * Rnd + 0.5)
D = D + 1
If D = IMax Then ER = R + 1: EC = C: R = 60000
Next
Next
TMP.Range(TMP.Cells(1, 1), TMP.Cells(60000, MxC)).Value = SampDt()
TMP.Cells(ER, EC) = FF
MsgBox "処理時間..." + Chr$(13) + Chr$(13) + "開始 : " + ST$ + Chr$(13) + Chr$(13) + "終了 : " + Time$ + Chr$(13) + Chr$(13) + "作成件数 : " + CStr(D) + " 件"
End Sub