|
>「""」が付いてしまい
これはたぶんセル内改行があるからでしょう。
下記コードをお試しください。^d^
Sub SaveTxt()
Dim myColumn As Range
Dim myCell As Range
Dim myLastCell As Range
Dim myRow As Range
Dim Fname As String
Dim N As Integer
Dim i As Integer
Set myColumn = ActiveSheet.UsedRange
Set myColumn = myColumn.Columns(1)
Fname = ThisWorkbook.Path & "\Test.txt"
N = FreeFile(0)
Open Fname For Output As #N
For Each myCell In myColumn.Cells
With myCell
Set myLastCell = .EntireRow
Set myLastCell = myLastCell.Cells(myLastCell.Cells.Count)
Set myLastCell = myLastCell.End(xlToLeft)
If myLastCell.Column < myCell.Column Then
Set myRow = myCell
Else
Set myRow = .Worksheet.Range(myCell, myLastCell)
End If
End With
With myRow
Print #N, .Cells(1).Value;
For i = 2 To .Cells.Count
Print #N, vbTab; .Cells(i).Value;
Next
Print #N, ""
End With
Next
Close #N
Set myColumn = Nothing
Set myCell = Nothing
Set myLastCell = Nothing
Set myRow = Nothing
End Sub
|
|