Try this,
I used a sheet names "Start". When you run the code, the code will delete all the sheets except sheets("Start")
Sub OPenMultipleWorkbooks()
'Open Multiple .csv files, this workbooks name is, 'Compare Workbook.xlsm'
Dim wb As Workbook
Dim GetFile As Variant
Set wb = ThisWorkbook
Application.DisplayAlerts = False
For Each Sheet In Sheets
If Sheet.Name <> "Start" Then Sheet.Delete
Next Sheet
ChDrive "C:"
GetFile = Application.GetOpenFilename(FileFilter:="CSV (*.CSV), *.CSV", Title:="Open CSV File", MultiSelect:=True)
Application.ScreenUpdating = False
On Error Resume Next
If GetFile <> False Then
On Error GoTo 0
For i = 1 To UBound(GetFile)
Workbooks.Open Filename:=GetFile(i)
Sheets(1).Move Before:=wb.Sheets(1)
Next i
End If
CombineDts
End Sub
Sub CombineDts()
Dim LstRw As Long, rng As Range, sh As Worksheet
Dim Frmla As String
Frmla = "=DATEVALUE(C2&"" / ""&D2&"" / ""&B2)"
For Each sh In Sheets
With sh
If .Range("A1") = "ID" Then
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A2:A" & LstRw)
rng = Frmla
rng.Value = rng.Value
rng.NumberFormat = "dd/mm/yyyy"
.Range("A1") = "Date"
.Columns("B:D").Delete Shift:=xlToLeft
End If
End With
Next sh
End Sub
Bookmarks