VBA & Macro Problems

Convert Hebrew CSV Files to XLSX with Excel VBA

Camila MilosovichCamila Milosovich Nov 20, 2026 868 views

Question details

Convert multiple Hebrew CSV files to XLSX with VBA while preserving Hebrew characters and preventing date misinterpretation.

Convert Hebrew CSV Files to XLSX with Excel VBA
Product
Microsoft Excel VBA
Device & OS
Windows
Scenario
A user needs to automate conversion of CSV files saved with a Hebrew Windows encoding.
Observed behavior
Dates can be interpreted in the wrong order when CSV encoding and regional settings are not handled explicitly.
Before you start

Confirm the CSV encoding, delimiter, and date-column positions using a representative file. The example below assumes Windows-1255, comma-delimited data, and a date in the first column; change these settings if your files differ.

Solution 1Recommended

Batch-convert CSV files with Excel VBA and explicit import settings

Use this approach to create one XLSX file per CSV while preserving the specified date column as text.

The macro uses Windows code page 1255 and Local:=True. Regional settings alone cannot resolve ambiguous dates, so the example imports column 1 as text; add every date column to FieldInfo to prevent Excel from guessing its format.

1
Open the VBA editor

In Excel, open a macro-enabled workbook, press Alt+F11, and choose Insert > Module.

2
Paste the conversion macro

Paste this code into the module: Sub ConvertHebrewCsvToXlsx() Dim picker As FileDialog Dim fso As Object, folder As Object, file As Object Dim src As Workbook Dim outputPath As String Dim converted As Long, skipped As Long On Error GoTo HandleError Set picker = Application.FileDialog(msoFileDialogFolderPicker) picker.Title = "Select the CSV folder" If picker.Show <> -1 Then Exit Sub Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(picker.SelectedItems(1)) For Each file In folder.Files If LCase$(fso.GetExtensionName(file.Name)) = "csv" Then outputPath = fso.BuildPath(folder.Path, fso.GetBaseName(file.Name) & ".xlsx") If fso.FileExists(outputPath) Then skipped = skipped + 1 Else Workbooks.OpenText Filename:=file.Path, Origin:=1255, _ DataType:=xlDelimited, TextQualifier:=xlTextQualifierDoubleQuote, _ Comma:=True, Local:=True, _ FieldInfo:=Array(Array(1, xlTextFormat)) Set src = ActiveWorkbook src.SaveAs Filename:=outputPath, FileFormat:=xlOpenXMLWorkbook src.Close SaveChanges:=False Set src = Nothing converted = converted + 1 End If End If Next file MsgBox converted & " converted; " & skipped & " skipped because XLSX files already exist." Exit Sub HandleError: If Not src Is Nothing Then src.Close SaveChanges:=False MsgBox "Conversion stopped: " & Err.Description, vbExclamation End Sub

3
Set the import options

In the pasted code, change Origin:=1255 if the files use another encoding; for UTF-8, use Origin:=65001. If the delimiter is a semicolon, replace Comma:=True with Semicolon:=True. Update FieldInfo to list every date column, for example Array(Array(1, xlTextFormat), Array(3, xlTextFormat)).

4
Run and check the results

Place the cursor inside the macro, press F5, and select the CSV folder. Open several resulting XLSX files in Excel and check Hebrew text, column alignment, and dates; existing XLSX files with matching names are skipped.

Batch-convert CSV files with Excel VBA and explicit import settings
Text dates versus Excel dates: The listed date columns remain text, preserving their original order but not providing Excel date values for calculations. If every source date has a known day-month-year order, use xlDMYFormat for that column instead and verify the imported values.
Free Microsoft Office alternative

Work with CSV and XLSX files in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for an easier transition. It can open CSV files and save spreadsheets as XLSX, but it does not fix Excel VBA import behavior; check encoding, dates, and any macro compatibility separately.

Open CSV files and save spreadsheets as XLSXCompatible with Microsoft Excel XLSX filesFamiliar spreadsheet interface for easier migrationFree and lightweight for everyday office work
microsoft office alternative - wps office

Frequently Asked Questions

Which encoding should I use for a Hebrew Windows CSV?

If the file is encoded in Windows-1255, use Origin:=1255 in Workbooks.OpenText. If it is UTF-8, use Origin:=65001 instead; verify the encoding from the source or with a text editor.

Why are my dates reversed after importing the CSV?

Excel may interpret an ambiguous date using a different month-day order. In Workbooks.OpenText, set each date column in FieldInfo to xlTextFormat to preserve the original text, or use a specific date format such as xlDMYFormat when the source order is known.

Can I import more than one date column as text?

Yes. In the macro's FieldInfo argument, list each column number, such as Array(Array(1, xlTextFormat), Array(3, xlTextFormat)) for columns 1 and 3.

Will the macro overwrite an existing XLSX file?

No. It checks for an XLSX file with the same base name in the selected folder and skips that CSV if the output already exists.