asked on
Sub ConvertCSVToXLSX()
Dim fso As Object
Dim FolderPath As String
Dim srcFolder As Object
Dim file As Object
Dim wb As Workbook
Dim FileName As String
Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject")
FolderPath = ThisWorkbook.Path
Set srcFolder = fso.GetFolder(FolderPath)
For Each file In srcFolder.Files
If fso.GetExtensionName(file) = "csv" Then
Set wb = Workbooks.Open(file)
FileName = Left(file.Name, InStr(file.Name, ".") - 1)
FileName = FileName & ".xlsx"
wb.SaveAs FolderPath & "\" & FileName, 51
wb.Close True
fso.DeleteFile (file)
End If
Next file
Application.ScreenUpdating = True
End Sub
ASKER
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY