+ Reply to Thread
Results 1 to 2 of 2

Named range name

  1. #1
    Registered User
    Join Date
    05-15-2009
    Location
    Weesp, Holland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Named range name

    Hi everyone,

    I have a procedure which retrieves data from an Access database to Excel, which is working just fine.

    However each time when I run the code to update the data in my sheet the named range assigned to the data array is updates with a sequence number.

    This is an excerpt of the code:

    vendor = "'ExampleData'"

    With ActiveSheet.QueryTables.Add(Connection:=varConnection, Destination:=Range("A1"))
    .CommandText = sqlstr
    .Name = vendor
    .Refresh BackgroundQuery:=False
    End With


    So the first time I run it the named range is called: "ExampleData"
    The next time "ExampleData__1" followed by "ExampleData__2" etc.

    How can I overwrite the old named range with a new one so the name remains the same?

    Thanks!

    Regards,

    Michel

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Named range name

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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