我一直在使用代码将数据从 excel 复制到 .txt 删除任何不需要的字符,以便输入到另一个应用程序:
Public DirRoot As String
Public CasNam As String
Public Sub Export()
Dim intUnit As Integer
Dim rngRow As Range
Dim rngCell As Range
Dim strText As String
intUnit = FreeFile
DirRoot = "C:\temp\"
CasNam = "Test"
Open DirRoot & CasNam & ".txt" For Output As intUnit
'End If
With Worksheets("Export").UsedRange
For Each rngRow In .Rows
strText = ""
For Each rngCell In rngRow.Cells
If Len(rngCell.Value) = 0 Then Exit For
strText = strText & " " & rngCell.Value
Next
Print #intUnit, Trim(strText)
Next
End With
Close intUnit
End Sub
现在我需要在一组不同的数据下使用它,其中一列是格式为:的日期yyyymmdd
,当我应用上面的代码时,我得到格式为的列dd/mm/yyyy
。
有什么办法可以将原始日期格式从 excel 保存到.txt
?
非常感谢您的帮助!