我怎样才能删除;从txt文件标记我从excel导出?
我正在使用以下宏导出txt文件:我怎样才能删除;从txt文件标记我从excel导出?,excel,vba,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 Fo
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
在导出文件的位置,该文件包含带有“”的每个单元格
例如,如果我选择的单元格包含:
1234,该文件包含“1234”
如何删除这些“”
谢谢
Alon这是当遇到字符串值时
write
的行为
更改为打印
,例如
If j = rng.Columns.Count Then
Print #1, cellValue
Else
Print #1, cellValue; ",";
End If
您是否尝试将
cellValue
设置为整数类型?以何种方式?这不会输出“”,除非单元格中有“”,单元格中没有“”,很抱歉,我忘了提到单元格也包含字母,如-A6GJHD6。那么问题是什么?它仍然导出带有“”的txt文件,即使我将其更改为“打印<代码>打印代码>也不会添加引号(我自己刚刚尝试过)是否删除该文件并重试?