+ Reply to Thread
Results 1 to 3 of 3

Thread: XlSheetVeryHidden code before close (Method Error)

  1. #1
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Belize
    MS-Off Ver
    Excel 2003, 2007
    Posts
    482

    XlSheetVeryHidden code before close (Method Error)

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        Select Case UCase(ws.Name)
            Case "Ark1", "Ark2"
                ws.Visible = True
            Case Else
                ws.Visible = xlSheetVeryHidden
        End Select
    Next ws
    End Sub
    I'm getting a:
    Method 'Visible' of Object '_Worksheet' failed
    What am I doing wrong? Thanks for you help.

    Ron
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: XlSheetVeryHidden code before close (Method Error)

    hi,
    see if it helps you
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        Select Case (ws.Name)
            Case "Ark1", "Ark2"
                ws.Visible = True
            Case Else
                ws.Visible = xlSheetVeryHidden
        End Select
    Next ws
    Regards, John

  3. #3
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: XlSheetVeryHidden code before close (Method Error)

    you're welcome! thx for rep!
    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes.
    Regards, John

+ 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.2.0