refreshing imported tables

uklobster

New Member
Joined
Dec 3, 2003
Messages
30
I have two csv tables imported into a spreadsheet and would like to automate the 'refreshing data' part so its run froma macro.

I have recorded a macro which should do the trick, but when I run it it falls over and cannot find the CSV file. The import text file dialogue box comes up, but until i click the file type 'text file' and reset it back to 'text file' the CSV isnt visible.

The two downloads are set to go straight to c:\data

Is there a way in VB to locate and load up the correct file ?

At the moment the macro code is...
Selection.QueryTable.Refresh BackgroundQuery:=False
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Before you try to load the file, add the following code in the macro:

chdir c:\data

This should ensure that it is looking in the correct folder.
 
Upvote 0
Thanks for the reply, but it doesnt solve the problem.

The directory seems to be ok, its just that Excel doesnt recognise the CSV file the table is linked to. But, when I change the open dialogue box from 'Text File' and then sent it back to 'Text File' again - the CSV suddenly becomes visible again and I can then select it and open the table to refresh the data.

Can I specify the file and the location so the open data source dialogue box doesnt open ?

Thanks for all your help
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,831
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top