External Data Text file Refresh Macro

Will Graham

New Member
Joined
Oct 22, 2009
Messages
8
I have a text.CVS file I down load daily off a server. I have used Get External Data From Text. Works well. I want to write a VBA sub to refresh the link as part of a large reporting package
What I have is:

Selection.QueryTable.Refresh BackgroundQuery:=False

But when it runs it asks/promts me for the file name. I don't want the entire application to stop here. How do I tell it to use the same file? with out stoping?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
This question is being answered from an Excel 2003 POV, but it should be applicable to 2007 as well.

Turn on the macro recorder while you run the External Data command and you will get code you can edit to re-run the query. The line you posted is the last line of a block of ~17 commands that set up a query.

I usually preface the resulting code with something like this to ensure that the query count does not build up, and no data remains from previous queries:
Code:
    For iX = ActiveSheet.QueryTables.Count To 1 Step -1
        ActiveSheet.QueryTables(iX).Delete
    Next
    Range("A1").CurrentRegion.Cells.Clear
    Range("A1").Select
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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