+ Reply to Thread
Results 1 to 8 of 8

Overite Cells VBA Query Code

  1. #1
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Overite Cells VBA Query Code

    Hi,

    I currently have the following VBA code that imports data from a Dbf file into an Excel spreadsheet but even though it clears the sheet before i run it if i run if twice it "inserts" cells shift the remaining cells to the right

    Any ideas of how to set the code to overate existing cells would be great


    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Overite Cells VBA Query Code

    Hi

    You can programmatically set the RefreshStype property - eg before your oQT.Refresh line include the line:

    Please Login or Register  to view this content.
    For testing your Regular Expression patterns, try my Regular Expression Pattern Testing add-in!

    For notes on how to use it - see here.

  3. #3
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Overite Cells VBA Query Code

    Quote Originally Posted by Firefly2012 View Post
    Hi

    You can programmatically set the RefreshStype property - eg before your oQT.Refresh line include the line:

    Please Login or Register  to view this content.
    Thanks for this but when running the code i get an Run-Time error 1004, Cannot complete operation: A table cannot overlap with a pivot table report, query results, a table, merged cells, or an XML mapping

    Any ideas??

    Thanks

  4. #4
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Overite Cells VBA Query Code

    If you're doing this in xl2010 then usually the querytable is contained within a ListObject, so try amending your querytable delete code to:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Overite Cells VBA Query Code

    Ignore my previous post - I don't think it is relevant to your situation. i think all you need to do is ensure you refresh the data synchronously (rather than asynchronously as you have it at the moment). I think what is happening is that when you click it a second time, the first refresh hasn't completed meaning you end up with two query tables on the sheet. You can avoid this happening by amending your Refresh line to:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Overite Cells VBA Query Code

    Thanks for all of these but I'm still getting cells inserted rather than overwritten when running the code more than once!!

    I've tried differnt combinations of the code but still no joy.

    Thanks anyway

  7. #7
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Overite Cells VBA Query Code

    Did you try combining?

    Please Login or Register  to view this content.
    Also, i you have the sheet open that contains the returned data, can you open the VBE, open up the Immediate Window (Ctrl+g) and type into it:

    Please Login or Register  to view this content.
    Don't omit the leading ?. Please let me know in your reply what it returns.

  8. #8
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Overite Cells VBA Query Code

    Hi Firefly,

    I've tried the above and still no joy. When i insert the code into the Immediate window it displays 1

    Any ideas??

    Thanks

+ 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