|
こんばんは
こんな感じです。標準モジュールの先頭から、
Type rFormat
A列郵便番号 As String * 8
B列住所 As String * 40
C列電話番号 As String * 11
D列名前 As String * 21
End Type
Sub test()
Dim rFmt As rFormat
Dim fN As Integer
Dim mArray
Dim i As Long
Dim j As Long
Dim Sh1 As Worksheet
Set Sh1 = Worksheets("Sheet1")
mArray = Sh1.Range("A1").CurrentRegion.Value
j = UBound(mArray, 1)
fN = FreeFile
Open "C:\TEST\AAA.txt" For Binary As #fN
For i = 1 To j
rFmt.A列郵便番号 = StrConv(mArray(i, 1), vbNarrow) & String(8, " ")
rFmt.B列住所 = StrConv(mArray(i, 2), vbWide) & String(40, " ")
rFmt.C列電話番号 = StrConv(mArray(i, 3), vbNarrow) & String(11, " ")
rFmt.D列名前 = StrConv(mArray(i, 4), vbWide) & String(21, " ")
Put #fN, , rFmt
Put #fN, , vbCrLf
Next
Close #fN
End Sub
|
|