View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default Combining On Open Macros

Why not play safe? Defensively written code:

Sub testIt2()
Dim ThisMth As String, aWS As Worksheet
ThisMth = Format(Now(), "mmm")
With ActiveWorkbook
.Worksheets(ThisMth).Visible = True
For Each aWS In .Worksheets
aWS.Visible = aWS.Name = ThisMth
Next aWS
End With
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Thanks Bob! Didn't think about that. I like your code. How about this
small idea?
iLastMonth = ((MyMonth + 10) Mod 12) + 1

If the op has only 3 sheets, and I want to try to salvage my code, perhaps
this small change then.
Select Case MyMonth
Case 1 To 3
Sheets("Jan").Visible = True ' Visible for now
Sheets("Feb").Visible = MyMonth = 2
Sheets("Mar").Visible = MyMonth = 3
Sheets("Jan").Visible = MyMonth = 1 ' Do Jan
Case Else
' Not sure...
End Select

Again, just throwing out some general ideas.