+ Reply to Thread
Results 1 to 10 of 10

Compile Error in Hidden Sheet

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Worcester, England
    MS-Off Ver
    Excel 2007
    Posts
    19

    Compile Error in Hidden Sheet

    Hi All.

    I've written some VB code in Excel 2003 which hides and unhides worksheets dependant upon 'Yes' or 'No' in a named range. This works Ok in Excel 2003, however if I try and use it in Excel 2007 it shows error 'Compile Error in Hidden Sheet'. When I debug it the error 'Compile Error - Method or Data Member Not Found' appears. The code in question is as follows:
    Please Login or Register  to view this content.
    This code is repeated for other worksheets, and VB highlights the line section 'Range("Email_Check")' as being the problem. Any help greatly appreciated.

    Simon
    Last edited by Simon Austin; 01-15-2009 at 12:04 PM. Reason: Problem Solved

  2. #2
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    Have you checked whether named ranges eg. Email_Check exist ...

    May be you have created manually in 2003.. but you forgot to create it in 2007

  3. #3
    Registered User
    Join Date
    01-14-2009
    Location
    Worcester, England
    MS-Off Ver
    Excel 2007
    Posts
    19
    Thanks for the response Shijesh. All of the named ranges exist. I've had Excel 2007 installed on my laptop now and it works ok! If I email the file to another user it doesn't work. There are no other instances of VB in the file and no references to calendars, only the instances which hide the sheets. I've saves as .xlsm extention and distributed and this doesn't work either.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    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

    I will add them this time.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your code naming is confusing.

    You use cell in the for next, but don't declare it as a variable.
    Is Email_Cell a range of cells?
    You dim Email_Check but don't set it.

    Your code appears to loop through a range of cells hiding/unhiding the same sheet.

  6. #6
    Registered User
    Join Date
    01-14-2009
    Location
    Worcester, England
    MS-Off Ver
    Excel 2007
    Posts
    19
    Thanks royUK. Apologies for posting the code incorrectly. I take on board your comments and will apply, however I am still a little confused why it works on my laptop but not on any others. I'll update and advise, but if you have any thoughts on the code working for me and nobody else let me know.

    Thanks

    Simon

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

    I am trying to follow the logic behind your code. If your are unhiding a worksheet based on cell's value, why are you using a loop? The last cell comparison will determine if the sheet is made visible or not.
    Please Login or Register  to view this content.
    Your code syntax is wrong as well. I don't see how this code as it is written would work. The code should be written this way...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  8. #8
    Registered User
    Join Date
    01-14-2009
    Location
    Worcester, England
    MS-Off Ver
    Excel 2007
    Posts
    19
    Thanks Leith.

    Your code works on my laptop, I'll distribute and see if if has done the trick!

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I still don't see why you are looping through a range & opening/closing the same sheet

  10. #10
    Registered User
    Join Date
    01-14-2009
    Location
    Worcester, England
    MS-Off Ver
    Excel 2007
    Posts
    19
    All sorted. Leith Ross' code worked a treat. Thanks all for your help.

    Simon

+ 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