Web Query Name

CalvinGraham

Board Regular
Joined
Jan 27, 2010
Messages
67
This has been driving me demented. I've been putting together a macro that pulls data from Google Finance but every time, it's adding more and more name ranges. I'm trying to pull it through as "ExternalQuery" but it keeps calling it "ExternalQuery_1" , "ExternalQuery_2" etc and when I go to rename it chucks out the usual "A query with this name already exists on this sheet" even though I'm actively removing them. I've tried restarting the application, manually removing names, using code to remove names and it still insists on adding numbers due to non-existant names. :mad::mad::mad::mad:


Code:
        'Web query
        With ThisWorkbook
            For Each nQuery In Names
                If IsNumeric(Right(nQuery.Name, 1)) Or nQuery.Name = "ExternalQuery" Then
                    nQuery.Delete
                End If
            Next nQuery
        End With
        With ActiveSheet.QueryTables.Add(Connection:="URL;" & TheQuery, Destination:=Range("TheQueryAnchor"))
            .BackgroundQuery = True
            .TablesOnlyFromHTML = False
            .Refresh BackgroundQuery:=False
            .SaveData = False
            .Name = "ExternalQuery"
        End With
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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