Hello everyone...
I have a VBA code to convert CSV to excel, but some computers can't display it correctly. The text was garbled.
I tried adding TextFilePlatform, but I got an error even before the macro starts.
TextFilePlatform:=932 was incorrect but I don't know how to fix it.
Can anyone help?
Thank you in advance
I have a VBA code to convert CSV to excel, but some computers can't display it correctly. The text was garbled.
I tried adding TextFilePlatform, but I got an error even before the macro starts.
TextFilePlatform:=932 was incorrect but I don't know how to fix it.
Can anyone help?
Thank you in advance
VBA Code:
' Open the CSV file
Workbooks.OpenText Filename:=MyPath & LatestFile, DataType:=xlDelimited, Comma:=True, TextFilePlatform:=932
' Set the worksheet
Set ws = ActiveSheet
' Define the columns to be converted to date format (e.g., columns 2 and 4)
dateColumns = Array(2, 3)
'
' Loop through each column and convert to date format
For i = LBound(dateColumns) To UBound(dateColumns)
ws.Columns(dateColumns(i)).NumberFormat = "yyyy/mm/dd"
Next i
' Define the columns to be changed to text format (e.g., columns 1 and 3)
colToText = Array(1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40)
' Loop through the specified columns and change their format to text
For j = LBound(colToText) To UBound(colToText)
ws.Columns(colToText(j)).NumberFormat = "@"
Next j