+ Reply to Thread
Results 1 to 2 of 2

What part of code is causing a new named range?

  1. #1
    Registered User
    Join Date
    03-10-2014
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    70

    What part of code is causing a new named range?

    I have some VBA that connects to the internet to download a table.

    The code:

    Please Login or Register  to view this content.
    It's in a loop that ends up creating 1000+ new named ranges, all the same. I'm pretty sure it's this part:
    With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://finance.yahoo.com/q/hl?s=" & Range("S3").Value & "+Holdings", Destination:=Range( _
    "$AD$1"))

    But I don't know if I should stop it, or just delete it after.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: What part of code is causing a new named range?

    I would suggest creating the querytable once (.Add) and after that, inside the loop, use a refresh instead (.Refresh) so you're effectively using the same table over and over.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 07-29-2015, 02:32 PM
  2. [SOLVED] determining if cell is part of named range and what that named range is
    By stnkynts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2014, 07:56 PM
  3. [SOLVED] Issue w/dynamic named range causing Excel to crash
    By plasmas222 in forum Excel General
    Replies: 10
    Last Post: 03-07-2014, 08:18 PM
  4. Copy and paste named range at end of loop causing massive slowdown over time
    By Sccye in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2013, 07:03 AM
  5. Protect/Unprotect code causing out of range error in code
    By Petrolcb41 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2010, 02:34 PM
  6. referencing part of a named range
    By pete_22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-01-2008, 11:26 AM
  7. Named range causing really weird problems - HELP
    By Abbas in forum Excel General
    Replies: 0
    Last Post: 07-26-2006, 01:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1