您可以調整這短短的宏您的需求:
Option Explicit
Sub CSV_Maker()
Dim r As Range
Dim sOut As String, k As Long, M As Long
Dim N As Long, nFirstRow As Long, nLastRow As Long
Dim MyFilePath As String, MyFileName As String
Dim fs, a, mm As Long
Dim separator As String
ActiveSheet.UsedRange
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
nFirstRow = r.Row
separator = ","
MyFilePath = "C:\TestFolder\"
MyFileName = "whatever"
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(MyFilePath & MyFileName & ".csv", True)
For N = nFirstRow To nLastRow
k = Application.WorksheetFunction.CountA(Cells(N, 1).EntireRow)
sOut = ""
If k = 0 Then
sOut = vbCrLf
Else
M = Cells(N, Columns.Count).End(xlToLeft).Column
For mm = 1 To M
sOut = sOut & Cells(N, mm).Text & separator
Next mm
sOut = Left(sOut, Len(sOut) - 1)
End If
a.writeline (sOut)
Next
a.Close
End Sub
http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macexcel/data-從xlsx到csv-file/c90ab942-6c18-46a2-8ca1-33db6b6198a3?db = 5&auth = 1時保存更改 – cutzero
http://stackoverflow.com/questions/14762834/saving-to-csv- in-excel-lose-regional-date-format讀取死碼答案 – cutzero
哪個版本的Excel和哪種CSV版本? Excel 2013保存爲'CSV(逗號分隔)(* .csv)'對我而言並不表現您描述的行爲。 – pnuts