如何删除"从txt文件标记我从excel导出?

时间:2015-12-22 10:18:50

标签: excel vba

我正在使用此宏导出txt文件:

Sub txtfile()
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer

myFile = Application.DefaultFilePath & "\Tax Exemption Check Template.txt"

Set rng = Selection

Open myFile For Output As #1

For i = 1 To rng.Rows.Count
    For j = 1 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value

If j = rng.Columns.Count Then
    Write #1, cellValue
Else
    Write #1, cellValue,
End If
  Next j
Next i
Close #1
End Sub

在导出文件的地方,它包含每个单元格"" 例如,如果我选择的单元格包含:

<12>,该文件包含&#34; 1234&#34; 如何删除&#34;&#34;?

谢谢,

阿龙

1 个答案:

答案 0 :(得分:2)

这是遇到字符串值时write的行为。

更改为print,例如

If j = rng.Columns.Count Then
    Print #1, cellValue
Else
    Print #1, cellValue; ",";
End If