Automatically Refresh Excel Datasource

S

Stevie D

Hi,

I have a comma separated text file called TrainingGroupEvaluation.csv which
is exported from a database.

I have an Excel Workbook.that links to this text file and reds in data from
it to a worksheet called "Source_Data. I would like the worksheet to
automatically be refreshed with the data in this file when the workbook
opens.

My attempt is as follows: -

Sub Auto_Open()
Sheets("Source_Data").Select
Range("A2").Select
Selection.QueryTable.Refresh BackgroundQuery:=True
Cells.Select
Cells.EntireColumn.AutoFit
End Sub


When the workbook opens automatically nothing appears to happen. If I step
through the procedure I am prompted by the import text file dialogue to
specify the name of the textfile.

Can anybody help me please? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top