I have a workbook with sheets that I don't want anyone to see. I canhide them with the spreadsheet format command, but then my vba codecan't access them. Does anyone know how to unhide (and later rehide)from within the vba code? Thanks very much.
You can use following VBA code:You can change the "mysheet" with you sheet name. It will unhide the sheet ifit is hideen.Sub myload()Dim mkc1 As ErrorDim sheet1 As Stringsheet1 = "mysheet"For Each ws In WorksheetsIf ws.Name = sheet1 Thenedits = 1End IfNext wsif edits = 0 ThenElseIf Application.Worksheets(sheet1).Visible = True ThenElseApplication.Worksheets(sheet1).Visible = TrueEnd IfEnd IfEnd SubI hope it works
You can modify the following code to do what you want:' This makes all sheets visible (ie for calculations to be done)Sub all_visible()For Each Sh In SheetsSh.Visible = TrueNext ShEnd Sub'This makes the following sheets invisibleSub invisible1()Worksheets("Instructions").Visible = FalseWorksheets("Rankings").Visible = FalseEnd Sub
Thanks for the help. I looked for Hide, but didn't think to look forVisible. (I am happy to take your admonition to heart, but I thinkmaybe it makes more sense to ignore the questions that you findoffensively easy.)