Results 1 to 2 of 2

Thread: Hide sheets
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    May 2019
    Posts
    86
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Hide sheets

    I have a workbook with 4 sheets and a form.
    when i launch my workbook I have the form in front with 3 buttons to open the different sheets.
    Ont the sheets I have a button to bring you back to the form..looks like this.

    Sub openform()
    JFSmainsheet.Show False


    End Sub
    I would like to have the worksheets be minimized or hidden when this macro is run.
    hope this make ssense.

    tyvm

    Dean

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    6,331
    Post Thanks / Like
    Mentioned
    72 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Hide sheets

    Try this

    In the events of thisworkbook, enter the following code

    Code:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Sheets("Sheet1").Visible = 0
        Sheets("Sheet2").Visible = 0
        Sheets("Sheet3").Visible = 0
        ActiveWorkbook.Save
    End Sub
    
    
    Private Sub Workbook_Open()
        JFSmainsheet.Show
    End Sub

    In your userform

    Code:
    Private Sub CommandButton1_Click()
        Call HideSheets
        Sheets("Sheet1").Visible = -1
        Sheets("Sheet1").Select
    End Sub
    
    
    Private Sub CommandButton2_Click()
        Call HideSheets
        Sheets("Sheet2").Visible = -1
        Sheets("Sheet2").Select
    End Sub
    
    
    Private Sub CommandButton3_Click()
        Call HideSheets
        Sheets("Sheet3").Visible = -1
        Sheets("Sheet3").Select
    End Sub
    
    
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        Sheets("Main").Visible = -1
        Call HideSheets
    End Sub
    
    
    Sub HideSheets()
        Sheets("Sheet1").Visible = 0
        Sheets("Sheet2").Visible = 0
        Sheets("Sheet3").Visible = 0
    End Sub
    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •