Re: Convert all CSV files in a folder to excel files
Code
Sub Command1_Click()
c00 = "C:\Users\music\Downloads\exceltest\"
sn = Filter(Split(CreateObject("wscript.shell").exec("cmd /c Dir " & c00 & "*.txt /b").stdout.readall, vbCrLf), ".txt")
For j = 0 To UBound(sn)
Name c00 & sn(j) As c00 & Replace(sn(j), ".txt", ".csv")
Next
For j = 0 To UBound(sn)
With GetObject(c00 & Replace(sn(j), ".txt", "csv"))
.Sheets(1).Copy , 1
With .Sheets(.Sheets.Count).Columns(4)
For jj = 1 To 12
.Replace Choose(jj, "NO", "BA", "RG", "SO", "JA", "BE", "VE", "GR", "VI", "MA", "BJ", "OR"), Choose(jj, "B", "W", "R", "P", "Y", "L", "GY", "G", "V", "BR", "TA", "O")
Next
.Range("C1,E1,F1,I1,J1,N1,Q1,U1").EntireColumn.Delete
End With
.SaveAs replace(ThisWorkbook.Path & "\","\\","\") & Replace(.Name, ".csv", ""), 51
.Close
End With
Next
End Sub
Display More