Created
July 12, 2016 13:40
-
-
Save dragonken/790662a03c3ab4754c8eaa7dca588660 to your computer and use it in GitHub Desktop.
Excel export Selection to UTF-8 CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub saveUnicodeCSV() | |
'Excel export Selection to UTF-8 CSV file | |
Set oAdoS = CreateObject("ADODB.Stream") | |
oAdoS.Charset = "UTF-8" | |
oAdoS.Mode = 3 | |
oAdoS.Type = 2 | |
oAdoS.Open | |
Dim rng As Range | |
Dim row As Range | |
Dim cell As Range | |
Set rng = Selection | |
For Each row In rng.Rows | |
For Each cell In row.Cells | |
oAdoS.WriteText (",""" & cell.Text & """") | |
Next cell | |
oAdoS.WriteText (vbCrLf) | |
Next row | |
oAdoS.SaveToFile "export.csv", 2 | |
oAdoS.Close | |
Set oAdoS = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment