如何解决VBA到CSV文件:无效的过程调用或参数错误5
所以我一直在努力处理这段代码,对于VBA和一般的编码来说,它是相当陌生的。我以为这可以很好地存储值,但是我不确定为什么会收到无效的过程调用或参数。如果我不得不猜测,我认为是因为c.Text吗?但是我不确定用什么替换它。
Sub btn_ExportDJ()
Dim PHRow As Long,c As Range
Dim ExportDJ As String
Dim DowPrice As Range
Dim Filepath As String
Dim ws As Worksheet
Filepath = "C:\Users\tim\Desktop\DU21\INFO 3100\Project\dowprice.csv "
comma = ","
'Import the range DowPrice into the csv string ExportDJ
Set DowPrice = Range("A1:A202")
For Each c In DowPrice.Rows
If PHRow <> c.Row Then
'The line below is where it breaks currently'
ExportDJ = Left(ExportDJ,Len(ExportDJ) - 1) & vbCrLf & c.Text & comma
PHRow = c.Row
Else
ExportDJ = ExportDJ & c.Text & comma
End If
Next c
ExportDJ = Left(ExportDJ,Len(ExportDJ) - 1)
'delete the file if it already exists
If Len(Dir(Filepath)) > 0 Then
Kill Filepath
End If
Open Filepath For Append As #1
Print #1,ExportDJ
Close #1
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。