アットウィキロゴ

VBA05

Sub aaaa015_出力()

    Dim intFF As Integer            ' FreeFile値
    Dim strREC As String            ' 読み込んだレコード内容
    Dim strTitle As Variant         ' タイトル
    Dim GYO As Long                 ' セルの行
    Dim COL As Long                 ' セルのカラム

    ' FreeFile値の取得(以降この値で入出力する)
    intFF = FreeFile
    
    Cells.Clear
    
    'タイトル
    GYO = 1
    COL = 1
    For Each strTitle In Split("a01,a02,a03", ",")
        Cells(GYO, COL).Value = strTitle
        COL = COL + 1
    Next strTitle

    Open "E:\Documents\dev\trunk\vba\aaa01.txt" For Input As #intFF
    GYO = 2
    ' ファイルのEOF(End of File)まで繰り返す
    Do Until EOF(intFF)
        ' 改行までをレコードとして読み込む
        Line Input #intFF, strREC
        If InStr(strREC, "aaa1") > 0 Then
            If Cells(GYO, 1).Value <> "" Then
                GYO = GYO + 1
            End If
            strREC = Trim(Replace(strREC, vbTab, ""))
            Cells(GYO, 1).Value = strREC
        End If
        If InStr(strREC, "aaa2") > 0 Then
            If Cells(GYO, 2).Value <> "" Then
                GYO = GYO + 1
            End If
            strREC = Trim(Replace(strREC, vbTab, ""))
            Cells(GYO, 2).Value = strREC
        End If
        If InStr(strREC, "aaa3") > 0 Then
            If Cells(GYO, 3).Value <> "" Then
                GYO = GYO + 1
            End If
            strREC = Trim(Replace(strREC, vbTab, ""))
            Cells(GYO, 3).Value = strREC
        End If
        
    Loop
    ' 指定ファイルをCLOSE
    Close #intFF

End Sub
最終更新:2013年05月30日 00:14