Everyday I receive a report in a .csv format, and on a daily basis I will copy the data into an "INPUT" tab on my spread sheet. The data on this input tab keeps on growing every day with the information and I will import this data by:

  • Clicking the last row on the "INPUT" tab
  • Get external text data
  • Import the CSV with ; as my delimiter and inputting the data from row 2 on wards
  • Format the text to font Calibri 8pt

The CSV files that come in all have a date incrementing naming convention list so:


Were probably looking at about 5000 lines of data a day, and while it isn't the most time consuming task, we're looking at ways to simplify the process.

Is there any way I can create a macro which will grab the latest .csv file out of a folder and import the data using the process above automatically?

  • yes. you can achieve that via a macro. start by searching SO there are plenty of similar topics. You need some code to get started on SO. – user222864 Aug 29 '13 at 9:11

You can use the Workbooks.OpenText method to input in a new worksheet, then do Worksheets.Move method to bring into the current workbook (even after the "INPUT" tab).

Since you mentioned you do this daily, a way to automatically pull in today's .csv file would be:

Dim inputfilepath As String
inputfile = ActiveWorkbook.Path & "\" & Format(Date, "yyyymmdd") & ".csv"
'open file
Workbooks.OpenText Filename:=inputfile

You can specify parameters for .OpenText that set the .csv delimiters and other options that fit your .csv file.

You could then start copying to the last row in the "INPUT" tab by automatically finding the last row using the Range.end method:


This assumes you have no gaps in information in column A, and goes to the cell after the last cell with information - the same as selecting A1, then doing Ctrl-down.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.