This does all the formatting in memory so it should be pretty fast.
Option Explicit
Sub CSVconverter()
Dim wbCSV As Workbook, MyArr As Variant, NewArr As Variant
Dim LR As Long, NR As Long, i As Long, j As Long
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.AllowMultiSelect = False
.Filters.Add "CSV Files", "*.csv", 1 'default
.ButtonName = "SELECT"
.Title = "Select CSV file"
.Show
If .SelectedItems.Count > 0 Then
Set wbCSV = Workbooks.Open(.SelectedItems(1))
Else
Exit Sub
End If
End With
LR = Range("A" & Rows.Count).End(xlUp).Row
MyArr = Range("A1:N" & LR).Value
ReDim NewArr((WorksheetFunction.Count(Range("A1:N" & LR)) + 1000), 2)
NewArr(0, 1) = "Date": NewArr(0, 2) = "Value"
NR = 1
For i = 2 To UBound(MyArr, 1)
For j = 3 To 14
If IsDate(MyArr(1, j) & " " & MyArr(i, 2) & ", " & MyArr(i, 1)) Then
NewArr(NR, 1) = Format(DateValue(MyArr(1, j) & " " & MyArr(i, 2) & ", " & MyArr(i, 1)), "MM/DD/YYYY")
NewArr(NR, 2) = MyArr(i, j)
NR = NR + 1
End If
Next j
Next i
Sheets.Add
Range("A1:C" & UBound(NewArr)).Value = NewArr
Range("A:A").Delete xlShiftToLeft
Range("A:B").Sort Range("A2"), xlAscending, Header:=xlYes
ActiveSheet.Move
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=Replace(wbCSV.FullName, ".csv", "-NEW.csv"), FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close False
wbCSV.Close False
End Sub
Bookmarks