If you want to hide or unhide specific sheets in a workbook.
Here is the code-
Sub hide_specific_worksheets()
'it will hide all sheets which will be added to Array("Sheet1", "Sheet2") list
Dim abc()
Dim wk As Worksheet
Dim i As Integer
abc = Array("Sheet1", "Sheet2")
For i = LBound(abc) To UBound(abc)
For Each wk In ThisWorkbook.Sheets
If wk.Name = abc(i) Then
wk.Visible = xlSheetVeryHidden
Exit For
End If
Next wk
Next i
End Sub
Sub unhide_specific_worksheets()
'it will unhide all sheets which will be added to Array("Sheet1", "Sheet2") list
Dim abc()
Dim wk As Worksheet
Dim i As Integer
abc = Array("Sheet1", "Sheet2")
For i = LBound(abc) To UBound(abc)
For Each wk In ThisWorkbook.Sheets
If wk.Name = abc(i) Then
wk.Visible = xlSheetVisible
Exit For
End If
Next wk
Next i
End Sub
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
If you want to add a new pop up button on mouse right click menu and as soon as you click on it . It shows you multiple buttons with macro a...
-
you can use offset function to create a dynamic source for the pivot . Dyanmic source here means every time you add anew rows of data to the...
Very nice use of array and code works well. Nice if you have specific sheets to hide/unhide. Thank you!
ReplyDelete@Doug Thanks
ReplyDelete