Hi Jonathan,
This macro should do it for you.
1) Put all CSV file paths in "Column A"
2) Click the button
3) Macro opens each CSV file and put quotes around every cell, then saves with a "_" after file name.
Sub tester()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim ms1 As String
Dim ms2 As String
Dim c1 As Range
Dim r1 As Range
Set r1 = Range("A1:A100") 'Put all CSV file paths in this range...
For Each c1 In r1 'Loop each CSV workbook
If c1.Value <> "" Then
Workbooks.Open Filename:=c1.Value
ms1 = ms1 & vbCrLf & c1.Value
Dim cell As Range
Dim rng As Range
Set rng = Range("A1:Z1000") '<--- Change if more cells in CSV books...
For Each cell In rng 'For each cell in CSV Range... put quotes around...
If cell.Value <> "" Then
cell.Value = Chr(34) & cell.Value & Chr(34)
End If
Next cell
Dim file_path As String
Dim new_path As String
file_path = Application.ActiveWorkbook.FullName
new_path = Left(file_path, Len(file_path) - 4) & "_.csv"
ActiveWorkbook.SaveAs Filename:=new_path
ActiveWindow.Close
ms2 = ms2 & vbCrLf & new_path
End If
Next c1
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Original files:" & ms1 & vbCrLf & vbCrLf & "Modified files:" & ms2
End Sub
Bookmarks