|
A1 には "0"の個数、 B1 には 全角スペースの個数 が書き込んであり、
2行目以降のA列数値を RSet、B列文字列を LSetしていく
--- ということでいいですか?
参考です
Sub test2()
Dim io As Integer
Dim Filename As String
Dim i As Long
Dim m As Long, n As Long
Dim s1 As String, s2 As String, s As String
Filename = Application.GetSaveAsFilename("test2", "テキスト,*.txt")
If Filename = "False" Then Exit Sub
io = FreeFile()
Open Filename For Output As io
m = Range("A1").Value
n = Range("B1").Value
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
s1 = String$(m, "0")
s2 = String$(n, " ")
s = CStr(Cells(i, 1).Value)
Mid(s1, m + 1 - Len(s)) = s
Mid(s2, 1) = Cells(i, 2).Value
Print #io, s1; s2
Next
Close io
MsgBox "出力しました", , Dir$(Filename)
End Sub
|
|