+ Reply to Thread
Results 1 to 3 of 3

Hide or unhide sheets

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-03-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    123

    Hide or unhide sheets

    Hi there,

    I have a code that erase data in a sheet, but the sheet is hidden. the code work well when the sheet is visible, but I dont want it to be visible. How can I make add to the code to unhide the sheet, clear all the data, and hide it again? no password is needed.

    my code:

    Sub Help_Rectangle16_Click()
    
    'Overall warning
    
    'Clear Content of Drawings
         MSG2 = MsgBox("This action will remove the data in this database system.Do you want to continue?", vbYesNo, "Warning")
        If MSG2 = vbYes Then
            
       
    
            'Clear Content of Drawings
                MSG2 = MsgBox("Do you want to Delete the Drawings database?", vbYesNo, "Drawings?")
               If MSG2 = vbYes Then
                    Sheets("Drawings").Select
                    Cells.ClearContents
                    Range("A1").Select
               Else
                   MsgBox "Drawing database not deleted"
               End If
             'Clear Content of Issues
                MSG2 = MsgBox("Do you want to Delete the Issues database?", vbYesNo, "Issues?")
               If MSG2 = vbYes Then
                   Sheets("Issues").Select
                    Cells.ClearContents
                    Range("A1").Select
                    Sheets("Distribute").Select
                    Cells.ClearContents
                    Range("A1").Select
               Else
                   MsgBox "Issues database not deleted"
               End If
              'Clear Content of Participants
                MSG2 = MsgBox("Do you want to Delete the Participants database?", vbYesNo, "Participants?")
               If MSG2 = vbYes Then
                   Sheets("Participants").Select
                    Cells.ClearContents
                    Range("A1").Select
                    Sheets("Distribute").Select
                    Cells.ClearContents
                    Range("A1").Select
               Else
                   MsgBox "Participants database not deleted"
               End If
               'Clear Content of ProjectInfo
                MSG2 = MsgBox("Do you want to Delete the Project Info database?", vbYesNo, "Project Info?")
               If MSG2 = vbYes Then
                   Sheets("ProjectInfo").Select
                    Cells.ClearContents
                    Range("A1").Select
                   Else
                   MsgBox "ProjectInfo database not deleted"
               End If
        Else
            MsgBox "Operation cancelled"
        End If
    End Sub
    best regards,

    Jakes

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,638

    Re: Hide or unhide sheets

    Assuming your sheet is "Hsheet" Use this changed code.



    Sub Help_Rectangle16_Click()
    
    'Overall warning
        ActiveWindow.WindowState = xlMinimized
        Sheets("Hsheet").Visible = True
    
    'Clear Content of Drawings
         MSG2 = MsgBox("This action will remove the data in this database system.Do you want to continue?", vbYesNo, "Warning")
        If MSG2 = vbYes Then
            
       
    
            'Clear Content of Drawings
                MSG2 = MsgBox("Do you want to Delete the Drawings database?", vbYesNo, "Drawings?")
               If MSG2 = vbYes Then
                    Sheets("Drawings").Select
                    Cells.ClearContents
                    Range("A1").Select
               Else
                   MsgBox "Drawing database not deleted"
               End If
             'Clear Content of Issues
                MSG2 = MsgBox("Do you want to Delete the Issues database?", vbYesNo, "Issues?")
               If MSG2 = vbYes Then
                   Sheets("Issues").Select
                    Cells.ClearContents
                    Range("A1").Select
                    Sheets("Distribute").Select
                    Cells.ClearContents
                    Range("A1").Select
               Else
                   MsgBox "Issues database not deleted"
               End If
              'Clear Content of Participants
                MSG2 = MsgBox("Do you want to Delete the Participants database?", vbYesNo, "Participants?")
               If MSG2 = vbYes Then
                   Sheets("Participants").Select
                    Cells.ClearContents
                    Range("A1").Select
                    Sheets("Distribute").Select
                    Cells.ClearContents
                    Range("A1").Select
               Else
                   MsgBox "Participants database not deleted"
               End If
               'Clear Content of ProjectInfo
                MSG2 = MsgBox("Do you want to Delete the Project Info database?", vbYesNo, "Project Info?")
               If MSG2 = vbYes Then
                   Sheets("ProjectInfo").Select
                    Cells.ClearContents
                    Range("A1").Select
                   Else
                   MsgBox "ProjectInfo database not deleted"
               End If
        Else
            MsgBox "Operation cancelled"
        End If
    
        Sheets("Hsheet").Visible = False
        ActiveWindow.WindowState = xlMaximized
    
    End Sub

  3. #3
    Forum Contributor
    Join Date
    03-03-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: Hide or unhide sheets

    Thanks a lot! have a great day!

+ 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