Jump to content

CSV2XLS converter


Recommended Posts

this can be done in vba very quickly, so just do that,

Sub CSv_Converter()

    Dim fn As String
    Dim i As Long
    Dim CSVFiles() As String
    Dim myDir As String
    
    fn = Application.GetOpenFilename(filefilter:="CSV Files (*.csv),*.csv") 'launch file browser
    fn = Dir("*.csv") 'get csv files
    myDir = CurDir 'get current directory
    ReDim CSVFiles(0)
    
    If fn <> "False" Then
        CSVFiles(0) = fn
        Do
            fn = Dir
            If fn <> "" Then
                i = i + 1
                ReDim Preserve CSVFiles(i)
                CSVFiles(i) = fn 'store the csv filename found in the current directory
            Else
                Exit Do
            End If
        Loop While fn <> ""
    End If
    
    Application.ScreenUpdating = False
    'save each file to xls
    For i = 0 To UBound(CSVFiles)
        Workbooks.Open Filename:=myDir & "\" & CSVFiles(i)
        Application.DisplayAlerts = False 'prevents asking questions
        ActiveWorkbook.SaveAs Filename:=myDir & "\" & Replace(CSVFiles(i), ".csv", ".xls"), _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
        Activewindow.Close
    Next
    Application.ScreenUpdating = True
    
End Sub
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...