Private Sub loadCSV() Dim vFile As Variant vFile = Application.GetOpenFilename(FileFilter:="CSV File(*.csv),*.csv") If vFile = False Then Exit Sub End If With ActiveSheet.QueryTables.Add(Connection:="text;" & vFile, Destination:=Range("A1")) .AdjustColumnWidth = True .TextFilePlatform = 65001 .TextFileCommaDelimiter = True .Refresh BackgroundQuery:=False .Delete End With
End Sub Private Sub Workbook_NewSheet(ByVal Sh As Object) Call loadCSV End Sub Private Sub Workbook_Open() Call loadCSV End Sub
Comments