#shape附加到Excel宏创建的CSV文件中的日期值

时间:2017-07-13 10:23:22

标签: excel excel-vba csv vba

我遇到问题,CSV文件的输出中包含与日期和时间#相关的清晰#2017-06-25 18:35:00#。如何删除附加到日期时间的锐利。我希望它显示为2017-06-25 18:35:00

我正在使用的代码是VBA中的以下代码。代码有问题吗?我不希望#附加到日期时间。一些样品或提示会很棒!我很乐意听到你的消息!

Sub ToCSVFile()
    Dim csvFilePath As String
    Dim iCount As Long
    Dim jCount As Long
    Dim kCount As Long
    Dim maxRow As Long
    Dim maxCol As Long
    Dim fileNo As Integer
    Dim sheet_name As String
    Dim csv_file As String

    sheet_name = ActiveSheet.name
    csv_file = "my.csv"
    csvFilePath = "C:\Users\mypath\Documents\" & csv_file
    maxRow = ActiveSheet.Range("B2").End(xlDown).Row
    maxCol = ActiveSheet.Range("B2").End(xlToRight).Column
    fileNo = FreeFile
    Open csvFilePath For Output As #fileNo
    For iCount = 2 To maxRow
        For jCount = 2 To maxCol - 1
            Write #fileNo, Cells(iCount, jCount);
            kCount = jCount
        Next jCount
        Write #fileNo, Cells(iCount, kCount + 1)
    Next iCount
    Close #fileNo
'
End Sub

0 个答案:

没有答案
相关问题