|
▼KOCCI さん:
こんにちは。
>ただ、CSVといいながら、セパレータはカンマではなく@にしたいのです。
>対象列は5つ(A〜E)で、それぞれのセルは文字か空白です。
>
>"abcdef"@""@"xyz"@"lmn123"@""
>
>のように出力させたいのです
参考に
Sub Macro2()
Dim FName As String
Dim i As Long
Dim j As Long
Dim lCol As Long
Dim vD() As Variant
Dim vA As Variant
Dim strA As String
FName = "D:\Excel\Test7\CSV_AT.CSV"
With Worksheets(1)
vA = .Range("A1:D" & .Range("A" & .Rows.Count).End(xlUp).Row)
lCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
ReDim vD(1 To lCol)
End With
Open FName For Output As #1
For i = 1 To UBound(vA)
For j = 1 To lCol
vD(j) = Chr(34) & vA(i, j) & Chr(34)
Next
strA = Join(vD, "@")
Print #1, strA
Next
Close #1
End Sub
|
|