I'm using the following Macro (thanks to The_Barman for the code!) to import a CSV-file into a worksheet called Tickets. The problem is that there are some special character like Ü,Ä, etc. in it, so I would need to import the file in the UTF-8 format. Can anybody tell me how to add this to this code?
Thanks in advance!
Sub CSV_Import()
Dim ws As Worksheet, strFile As String
Worksheets("Tickets").Range("A1:Z9999").Clear
Set ws = ActiveWorkbook.Sheets("Tickets")
strFile = "C:\test\testfile.csv"
With ws.QueryTables.Add(Connection:="TEXT;" & strFile, Destination:=ws.Range("A1"))
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh
End With
End Sub
I added ".TextFilePlatform = 65001" to the code and it's working now:
Sub CSV_Import()
Dim ws As Worksheet, strFile As String
Worksheets("Tickets").Range("A1:Z9999").Clear
Set ws = ActiveWorkbook.Sheets("Tickets")
strFile = "C:\test\testfile.csv"
With ws.QueryTables.Add(Connection:="TEXT;" & strFile, Destination:=ws.Range("A1"))
.TextFileParseType = xlDelimited
.TextFilePlatform = 65001
.TextFileCommaDelimiter = True
.Refresh
End With
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With