使用自定义分隔符Excel保存文件



我想知道Excel是否可以用我可以选择的分隔符保存文件?

感谢

是的,这是可能的。转到Windows"控制面板"中的"区域和语言"设置。单击"格式"选项卡上的"其他设置"。将列表分隔符更改为您自己的自定义分隔符。

这可能会有所帮助:

Sub changeCharacter()
    Dim myFile As String
    Dim text As String
    Dim textline As String
    myFile = Application.GetOpenFilename() 'open your TXT/CSV file
    Open myFile For Input As #1 'open just for input
    Do Until EOF(1)
        Line Input #1, textline
        textline = Replace(textline, ",", "#")
        text = text & Chr(10) & textline
    Loop
        '#####################################3
        'EOF = End Of File
        ' and this function sends true when reach the last
        ' line of the file...
        '
        'Line Input #1, textline
        ' take the next line in the TXT/CSV file an store it inside
        ' "textline" to replace the character "," for "#" using:
        'textline = Replace(textline, ",", "#")
        ' and store the result again inside "textline"
        ' and finally, store the result into "text" to use it later
        '#####################################3
    Close #1 'close the TXT/CSV fiel
    Open myFile For Output As #1 'open the same file againg,
                                 'now to store the resulting data
                                 'inside the file
    Write #1, text 'write the data into the file
    Close #1 'close it againg, now with the changes...
End Sub

这不是为了用不同的delimeter保存文件,但可能有助于更改它。

最新更新