![見出し画像](https://assets.st-note.com/production/uploads/images/140059845/rectangle_large_type_2_49ffd50159e54e38a661d4bf6c285a05.png?width=1200)
memo text変換
Sub output()
'変数宣言
Dim maxRow, maxCol As Long
Dim name, data, path As String
'最終行・最終列取得
maxRow = Cells(1, 1).End(xlDown).Row
maxCol = Cells(1, 1).End(xlToRight).Column
'1行ずつ書き出し
For i = 1 To maxRow
'名前(A列)
name = Cells(i, 1).Value
'データ内容(B~列)
data = ""
For j = 1 To maxCol
data = data & " " & Cells(i, j + 1).Value
Next
'出力ファイル名
path = ThisWorkbook.path & "\" & name & ".txt"
'空いているファイル番号を取得
FileNumber = FreeFile
'ファイルをOutputモードで開く
Open path For Output As #FileNumber
'ファイルにデータを書き込む
Print #FileNumber , Right(data, Len(data) - 1)
'ファイルを閉じる
Close #FileNumber
Next
End Sub
この記事が気に入ったらサポートをしてみませんか?