+ Reply to Thread
Results 1 to 8 of 8

Run-time error 1004: Method Visible of object_Worksheet failed

  1. #1
    Registered User
    Join Date
    11-20-2017
    Location
    Evansville, Indiana
    MS-Off Ver
    2010
    Posts
    3

    Run-time error 1004: Method Visible of object_Worksheet failed

    The file has worked properly for nearly a year now but suddenly has given the run time error message and allows other users to bypass the username/passcode section. When I cliecked onthe debug button, it highlighted the Sub VisibleFalse section on line ws.Visible = xlVeryHidden - I do not know how to fix this error.

    I copied/pasted the entire string of code

    Sub Showme()
    frmLogin.Show
    End Sub

    Sub Toggle()
    ActiveWindow.DisplayWorkbookTabs = Not ActiveWindow.DisplayWorkbookTabs
    End Sub

    Sub GetSheets()
    'add the sheet names to the sheet
    Sheet2.Range("Q8:Q108").ClearContents
    Dim i As Integer
    For i = 1 To Sheets.Count
    Sheet2.Range("Q" & i + 7) = Sheets(i).Name
    Next i
    End Sub

    Sub VisibleTrue()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Sheets
    ws.Visible = True
    Next ws
    ActiveWindow.DisplayWorkbookTabs = True
    Sheet1.Select
    End Sub

    Sub VisibleFalse()
    Dim ws As Worksheet
    GetSheets
    'loop through each sheet
    For Each ws In Worksheets
    'use the case statement to exclude sheets by sheet name
    Select Case ws.Name
    'add the name of the sheets to exclude
    Case "Interface"
    'Case "Login"
    'protect the rest
    Case Else
    ws.Visible = xlVeryHidden
    End Select
    Next ws
    End Sub

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Run-time error 1004: Method Visible of object_Worksheet failed

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    BTW - I tested your code for the VisibleFalse routine and it runs nicely - something else must be going on
    Last edited by xladept; 11-20-2017 at 04:32 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Valued Forum Contributor
    Join Date
    12-01-2016
    Location
    Planet Earth
    MS-Off Ver
    95 - 2016
    Posts
    343

    Re: Run-time error 1004: Method Visible of object_Worksheet failed

    Your issue seems to be within the last code

    Does the worksheet Interface still exist? If so, check for spelling error(s) or trailing spaces.

  4. #4
    Registered User
    Join Date
    11-20-2017
    Location
    Evansville, Indiana
    MS-Off Ver
    2010
    Posts
    3

    Re: Run-time error 1004: Method Visible of object_Worksheet failed

    Yes the worksheet Interface still exists - I checked it for spelling errors and trailing spaces & it was good. The one thing I did notice is someone accidentally protected the workbook so I'm not sure if that has now overridden the VBA & the person does not remember what password they used....

  5. #5
    Valued Forum Contributor
    Join Date
    12-01-2016
    Location
    Planet Earth
    MS-Off Ver
    95 - 2016
    Posts
    343

    Re: Run-time error 1004: Method Visible of object_Worksheet failed

    Yes. The error can be produced if the workbook is password protected.

    Unfortunately, this has turned into a password protection issue, and I must inform you that we will not be able to assist you further since it would not comply with Rule 11 of the Forum RULES.

  6. #6
    Registered User
    Join Date
    11-20-2017
    Location
    Evansville, Indiana
    MS-Off Ver
    2010
    Posts
    3

    Red face Re: Run-time error 1004: Method Visible of object_Worksheet failed

    Thank you all very much for assisting me.I appreciate any help I can get since I am not an expert in this area.

  7. #7
    Valued Forum Contributor
    Join Date
    12-01-2016
    Location
    Planet Earth
    MS-Off Ver
    95 - 2016
    Posts
    343

    Re: Run-time error 1004: Method Visible of object_Worksheet failed

    If that takes care of your original question, please select Thread Tools from the menu link above your original post and mark this thread as SOLVED. Thanks.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Run-time error 1004: Method Visible of object_Worksheet failed

    You're welcome and thanks for the rep!

+ 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. [SOLVED] Getting run-time error 1004 method of object_global failed
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-20-2017, 02:17 AM
  2. [SOLVED] Runtime Error: 1004 Method 'Visible' of Object "_Worksheet' failed
    By Sorjas in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-15-2015, 02:29 AM
  3. Run-Time Error '1004': Method 'Visible' of Object'_Worksheet' Failed
    By caltman242 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2015, 10:43 AM
  4. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  5. [SOLVED] Error - Method Range of object_worksheet failed
    By pjbassdc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-02-2013, 03:55 PM
  6. Run time error 1004 select method of class failed
    By Doruli in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-14-2013, 04:50 AM
  7. Replies: 7
    Last Post: 08-24-2005, 11:05 AM

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