☆エコ・ソート/サンプル 〔2〕


'
' RecNo Macro
' マクロ作成日 : 2008/8/27 ユーザー名 : 寺田屋の龍馬
'
' 1~100万番のレコード番号をシート2に作成

'
ST$ = Time$

    Dim S2 As Worksheet
    Set S2 = Worksheets("Sheet2")

    Dim R As Long, C As Integer, D As Long, ER As Long, MxC As Integer, IMax As Long
    Dim SampID(), FF As String

    S2.Range("A1:IV65536").ClearContents

    IMax = 1000000 '対象レコード数

    MxC = (IMax - 1) \ 65535 + 1: FF = String(16, Chr(-1))

    SampID() = S2.Range(S2.Cells(1, 1), S2.Cells(65535, MxC * 2)).Value
    D = 0

    For C = 1 To MxC

        For R = 1 To 65535

            D = D + 1

            SampID(R, C * 2) = D

            ER = R
            If D = IMax Then R = 65535

        Next

        S2.Cells(ER + 1, C * 2 - 1) = FF

    Next

    S2.Range(S2.Cells(1, 1), S2.Cells(65535, MxC * 2)).Value = SampID()

MsgBox "処理時間..." + Chr$(13) + Chr$(13) + "開始 : " + ST$ + Chr$(13) + Chr$(13) + "終了 : " + Time$ + Chr$(13) + Chr$(13) + "作成件数 : " + CStr(D) + " 件"

End Sub

© Rakuten Group, Inc.
X
Design a Mobile Site
スマートフォン版を閲覧 | PC版を閲覧
Share by: