View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Show Tabs by date

Tiny niggle: If the user has manually hidden one or more sheets,
including sheet "Jan", it is possible to get a run-time error with this
technique since at least one sheet must remain visible.



In article . com,
JW wrote:

The prompt is not really necessary. I just put it in for
demonstration purposes.
Sub sheetHider()
Dim mthList As Variant, sht As Worksheet
mthList = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
If Month(Date) < 12 Then
For mth = Month(Date) + 1 To 12
For Each sht In ActiveWorkbook.Worksheets
If sht.Name = mthList(mth - 1) Then
sht.Visible = xlSheetHidden
End If
Next sht
Next mth
End If
End Sub