Microsoft Access 掲示板

カラムにデータがあったら、別のカラムにデータを入力する方法 / 25

26 コメント
views
4 フォロー
25

ご参考に。

Sub kansei2(fn As String)
    Dim txt As String
    Dim strName(1) As String
    With Sheets("sheet1")
        strName(0) = WorksheetFunction.TextJoin(",", True, .Cells(1, 1).Resize(, 6))
        strName(1) = WorksheetFunction.TextJoin(",", True, .Cells(4, 1).Resize(, 11))
    End With

    With CreateObject("Scripting.FileSystemObject").OpenTextFile(fn, 1)
        txt = .ReadAll
        .Close
    End With
    
    'Debug.Print strName(0) & vbCrLf & "[kanri]" & vbCrLf & ",001" & vbCrLf & strName(1)
    txt = strName(0) & vbCrLf & "[kanri]" & vbCrLf & ",001" & vbCrLf & strName(1) & vbCrLf & txt
    
    With CreateObject("Scripting.FileSystemObject").OpenTextFile(fn, 2)
        .Write txt
        .Close
    End With

End Sub

Sub Test()
    Call kansei2("C:\Users\tasuk\Desktop\A社保申告\SHFD0006temp - コピー.CSV")
End Sub
通報 ...