+ Reply to Thread
Results 1 to 4 of 4

Declaring the 'Worksheets object' As a 'Excel.Worksheets' variable

  1. #1
    Registered User
    Join Date
    03-26-2014
    Location
    Norway
    MS-Off Ver
    MS Office 365
    Posts
    25

    Declaring the 'Worksheets object' As a 'Excel.Worksheets' variable

    This works:
    Please Login or Register  to view this content.
    This results in "Run-time error '13'", 'Type mismatch':
    Please Login or Register  to view this content.
    Why is that?
    Last edited by Woulter; 12-15-2018 at 04:36 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Declaring the 'Worksheets object' As a 'Excel.Worksheets' variable

    Hello Woulter,

    You can make this work by dimming your object variable as a generic object...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    03-26-2014
    Location
    Norway
    MS-Off Ver
    MS Office 365
    Posts
    25

    Re: Declaring the 'Worksheets object' As a 'Excel.Worksheets' variable

    Yes, I'm just wondering why 'Sheets' and 'Worksheets' can't both be declared as 'Excel.Sheets'/'Excel.Worksheets'.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Declaring the 'Worksheets object' As a 'Excel.Worksheets' variable

    Hello Woulter,

    I am guessing here. The "Sheets"collection holds Charts, Worksheets, and Macro sheets. The Worksheets collection holds only the worksheets of the Active Workbook. It could be that assigning an object as "Ëxcel.Worksheets"creates a conflict in the application since the object already exists.

+ 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. VBA Update - Declaring Worksheets and Ranges
    By JSunRae in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2017, 03:52 AM
  2. Declaring variable for object..
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2014, 12:08 AM
  3. [SOLVED] Rename Excel Worksheets, Add Variable if worksheet name already exists
    By jessello in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2013, 05:38 PM
  4. Macro Using Excel Object: Comparing Two Worksheets from Two Different Workbooks
    By quixter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 11:49 AM
  5. Replies: 0
    Last Post: 04-04-2012, 08:12 AM
  6. View Object disabled for Excel worksheets
    By paul12d in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2011, 02:20 AM
  7. [SOLVED] Trouble with Declaring Worksheets
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-10-2005, 05:05 AM

Tags for this Thread

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