+ Reply to Thread
Results 1 to 6 of 6

Data Type Help

  1. #1
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Data Type Help

    Hi Everyone,

    I am trying to get into the habit of using option explicit. Therefore, I have to declare each variable.

    A piece of my script which will delete all query tables within a sheet. When I run my code, I get "Application-defined or object-defined error" message and it stops on this line:

    Please Login or Register  to view this content.
    Am I declaring the dest variable incorrectly as a range?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Data Type Help

    Hi Natalie,

    I think you need to "fully qualify" your qt.Destination.

    It might need Activesheet.qt.Destination or more qualifiers for the object to be fully determined.

    https://msdn.microsoft.com/en-us/vba...e-object-excel
    Last edited by MarvinP; 08-31-2017 at 11:10 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Type Help

    Hi,

    You would get a Type Mismatch error if the problem was with the variable type. If you view the Locals window while the code is in debug mode, what is shown for the qt.Destination property?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Data Type Help

    Try:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Type Help

    Quote Originally Posted by JOHN H. DAVIS View Post
    Try:

    Please Login or Register  to view this content.
    That won't work because it's not a named range. qt is a Querytable object and Destination is a property that returns a Range object.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Data Type Help

    @ xlnitwit - Thanks for the info. I never work with Querytable and didn't know.

+ 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: 3
    Last Post: 05-22-2016, 06:30 AM
  2. [SOLVED] multiple conditions to count large amount of data by Type, month & activity type
    By norfolk_lass in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-03-2014, 12:54 PM
  3. Replies: 0
    Last Post: 09-03-2013, 11:26 AM
  4. Replies: 1
    Last Post: 08-08-2012, 02:39 PM
  5. Copying rows of data depending on the data type in a column
    By mels in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2012, 02:58 AM
  6. [SOLVED] How to import column from dB and force data to a numeric data type?
    By Mike Hanby in forum Excel General
    Replies: 5
    Last Post: 07-11-2006, 05:13 PM
  7. create macro to move label type data to column data
    By JonathonWood9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2005, 07:06 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