Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Hiding/UnHiding Selected Worksheets

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Hiding/UnHiding Selected Worksheets

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Hiding/UnHiding Selected Worksheets

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Hiding/UnHiding Selected Worksheets

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hiding/unhiding rows Art Excel Worksheet Functions 1 March 16th 10 05:00 PM
Hiding Worksheets and Unhiding them easily for Novice User Jugglertwo Excel Discussion (Misc queries) 5 June 5th 07 02:53 PM
Hiding & Unhiding graphs... Ray Charts and Charting in Excel 1 February 21st 07 08:37 PM
Hiding & Unhiding Cells, How to Create a calendar drop down box Excel Discussion (Misc queries) 0 January 26th 07 05:12 PM
Hiding/Unhiding Bobby Excel Worksheet Functions 2 May 25th 05 10:40 PM


All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"