+ Reply to Thread
Results 1 to 7 of 7

Sheets(i).Select gives App-defined or Obj-defined error

  1. #1
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Sheets(i).Select gives App-defined or Obj-defined error

    Hi,

    The Sheets(i).Select line gives a runtime error "application-defined or object-defined error".

    Please Login or Register  to view this content.
    The code was copied from another workbook's Module 1 and ran ok there.

    This version runs further, until it reaches the Activesheet line, then gives the same error:
    Please Login or Register  to view this content.
    thanks,
    John

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Sheets(i).Select gives App-defined or Obj-defined error

    i don't know, it worked for me, I put 2 charts on sheet1, none on sheet2, and none on sheet3

    the second code box in your original post gave me 2,0,0 for the counts, so it did what it was supposed to, likewise Cnt gave me 1,-1,-1 again worked like it was supposed to


    i'm guessing that the code in the first code box in your original post is part of a longer macro, did you dim sht as worksheet? also are you doing a similar task of selecting the sheets to count the chart items?

    something else must be wrong

    further details please

  3. #3
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Sheets(i).Select gives App-defined or Obj-defined error

    Scott,
    Yes, I did Dim sht as Worksheet. I cut down the code to present only the relevant parts. In my full code, this particular sub is used to format row heights between the charts to 0.1 so they're effectively hidden. Other code sections actually manipulate individual chart options.

    I think I'll start fresh with a blank worksheet, and try again. Something not obvious is at work here.

    Thanks,
    /John

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Sheets(i).Select gives App-defined or Obj-defined error

    If there is hidden sheet, you will get that error.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Sheets(i).Select gives App-defined or Obj-defined error

    Your second set of code repeatedly returns the number of charts on the active sheet, so the loop isn't doing anything. I can't tell what you're trying to do, so can't make a suggestion.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Sheets(i).Select gives App-defined or Obj-defined error

    duplicate post removed
    Last edited by torrmundi; 02-04-2013 at 05:34 PM. Reason: duplicate post

  7. #7
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Sheets(i).Select gives App-defined or Obj-defined error

    Hi, sorry for the weekend delay - I'm back on this issue now. Thanks for the replies!
    So far:
    - I have no hidden sheets
    - I can open a fresh worksheet and run my macro successfully
    - I cannot run it on the worksheet I'm actually using.
    - There is no worksheet protection set
    - I can use a watch variable of Sheets(i) successfully; I just can't perform the Sheets(i).Select.
    Please Login or Register  to view this content.

+ 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