Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan
Last active July 22, 2017 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabrina-zeidan/a493760c8ca68947c3d3174dd04a8b66 to your computer and use it in GitHub Desktop.
Save sabrina-zeidan/a493760c8ca68947c3d3174dd04a8b66 to your computer and use it in GitHub Desktop.
This macros will bulk covert csv to xlsx in Excel. First, save csv to txt (just changing name.csv to name.txt in totalcommaner or similar, bulk in one click). Place to CSVfolder = "C:\csv\txt\" ,output will be here XlsFolder = "C:\csv\xlsx\"
Private Sub CommandButton2_Click()
Dim CSVfolder As String, _
XlsFolder As String, _
fname As String, _
wBook As Workbook
CSVfolder = "C:\csv\txt\"
XlsFolder = "C:\csv\xlsx\"
fname = Dir(CSVfolder & "*.txt")
Do While fname <> ""
Set wBook = Workbooks.Open(CSVfolder & fname, Format:=4)
wBook.SaveAs XlsFolder & Replace(fname, ".txt", ""), xlOpenXMLWorkbook
wBook.Close False
fname = Dir
Loop
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment