Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Again... how do I go about hiding/unHiding a selected set of worksheets
eg: I have worksheets named shHol1 thru shHol100 , how would I hide or unhide sheets 20 thru 32? This is the vba names, not the actual sheet names in excel... the sheets names are Jan - Dec. Thanks again! Craig |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Craig, here are a couple of methods, one is using the date formating
facilities and the other uses an array where there may be international language concerns. '-- method 1 Sub SheetsShow() ShowSheets True End Sub Sub SheetsHide() ShowSheets False End Sub Sub ShowSheets(ByVal Hide As Boolean) Dim i As Integer For i = 1 To 12 ActiveWorkbook.Worksheets(Format(DateSerial(2000, i, 1), "Mmm")).Visible = Hide Next i End Sub '-- method 2 Sub SheetsShowInternational() ShowSheets True End Sub Sub SheetsHideInternational() ShowSheets False End Sub Sub ShowSheetsInternational() Dim m As Variant Dim mm As Variant m = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") For Each mm In m ActiveWorkbook.Worksheets(mm).Visible = Hide Next mm End Sub -- HTHs Martin "Craig" wrote: Hi Again... how do I go about hiding/unHiding a selected set of worksheets eg: I have worksheets named shHol1 thru shHol100 , how would I hide or unhide sheets 20 thru 32? This is the vba names, not the actual sheet names in excel... the sheets names are Jan - Dec. Thanks again! Craig |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thank Martin, I used the array("Jan", "Feb",... method and it worked fine.
I'm having a problem understanding one part of the code; though. When you declare "M" as Variant and set "M" as array("Jan","Feb",... In the For Each mm in m I don't understand how or when "mm" was set? Craig "Martin Fishlock" wrote in message ... Craig, here are a couple of methods, one is using the date formating facilities and the other uses an array where there may be international language concerns. '-- method 1 Sub SheetsShow() ShowSheets True End Sub Sub SheetsHide() ShowSheets False End Sub Sub ShowSheets(ByVal Hide As Boolean) Dim i As Integer For i = 1 To 12 ActiveWorkbook.Worksheets(Format(DateSerial(2000, i, 1), "Mmm")).Visible = Hide Next i End Sub '-- method 2 Sub SheetsShowInternational() ShowSheets True End Sub Sub SheetsHideInternational() ShowSheets False End Sub Sub ShowSheetsInternational() Dim m As Variant Dim mm As Variant m = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") For Each mm In m ActiveWorkbook.Worksheets(mm).Visible = Hide Next mm End Sub -- HTHs Martin "Craig" wrote: Hi Again... how do I go about hiding/unHiding a selected set of worksheets eg: I have worksheets named shHol1 thru shHol100 , how would I hide or unhide sheets 20 thru 32? This is the vba names, not the actual sheet names in excel... the sheets names are Jan - Dec. Thanks again! Craig |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is a for each loop and each item in the array is used.
mm is set at the start of the loop and the next array item is used when the code reaches the next mm statement. -- HTHs Martin "Craig" wrote: thank Martin, I used the array("Jan", "Feb",... method and it worked fine. I'm having a problem understanding one part of the code; though. When you declare "M" as Variant and set "M" as array("Jan","Feb",... In the For Each mm in m I don't understand how or when "mm" was set? Craig "Martin Fishlock" wrote in message ... Craig, here are a couple of methods, one is using the date formating facilities and the other uses an array where there may be international language concerns. '-- method 1 Sub SheetsShow() ShowSheets True End Sub Sub SheetsHide() ShowSheets False End Sub Sub ShowSheets(ByVal Hide As Boolean) Dim i As Integer For i = 1 To 12 ActiveWorkbook.Worksheets(Format(DateSerial(2000, i, 1), "Mmm")).Visible = Hide Next i End Sub '-- method 2 Sub SheetsShowInternational() ShowSheets True End Sub Sub SheetsHideInternational() ShowSheets False End Sub Sub ShowSheetsInternational() Dim m As Variant Dim mm As Variant m = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") For Each mm In m ActiveWorkbook.Worksheets(mm).Visible = Hide Next mm End Sub -- HTHs Martin "Craig" wrote: Hi Again... how do I go about hiding/unHiding a selected set of worksheets eg: I have worksheets named shHol1 thru shHol100 , how would I hide or unhide sheets 20 thru 32? This is the vba names, not the actual sheet names in excel... the sheets names are Jan - Dec. Thanks again! Craig |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
hiding/unhiding rows | Excel Worksheet Functions | |||
Hiding Worksheets and Unhiding them easily for Novice User | Excel Discussion (Misc queries) | |||
Hiding & Unhiding graphs... | Charts and Charting in Excel | |||
Hiding & Unhiding Cells, How to | Excel Discussion (Misc queries) | |||
Hiding/Unhiding | Excel Worksheet Functions |