Hi All!
Is there a way to modify the code below so that when I import a new file, it starts the import on row 2 and adds the file name of the import to cell B1 and the date of import to cell A1? There isn't a header row in the file, it just imports the raw data from a csv file.
I've been messing around with it to at least get it to start the import on row 2, but keep getting a Type Mismatch error. As indicated from the comment in the code, I did find this code from MrExcel and modified it to work a while back....so far it's been working excellent, but now I need to include the file name so I know I'm working with the latest file.
Thanks, everyone!
Is there a way to modify the code below so that when I import a new file, it starts the import on row 2 and adds the file name of the import to cell B1 and the date of import to cell A1? There isn't a header row in the file, it just imports the raw data from a csv file.
I've been messing around with it to at least get it to start the import on row 2, but keep getting a Type Mismatch error. As indicated from the comment in the code, I did find this code from MrExcel and modified it to work a while back....so far it's been working excellent, but now I need to include the file name so I know I'm working with the latest file.
VBA Code:
Sub Import()
'info came from MrExcel.com and modified to work for this workbook
Dim strFile As String, wb As Workbook
'Open the File Dialog
With Application.FileDialog(3)
.AllowMultiSelect = False
'Show the dialog box
If .Show Then
'Store in fullpath variable
fullpath = .SelectedItems.Item(1)
'open the file
Set wb = Workbooks.Open(fullpath)
End If
If wb Is Nothing Then Exit Sub
'copy range from selected item into current worksheet
wb.Sheets(1).Range("A:L").COPY
ThisWorkbook.Worksheets("Import").Activate
ActiveSheet.Range("A:L").PasteSpecial
Columns("A:L").EntireColumn.AutoFit
Application.CutCopyMode = False
wb.Close False
End With
End Sub
Thanks, everyone!