LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Combining On Open Macros

Hello All,

I have two macros: 1 to Protect All Sheets and 1 to Hide
sheets based on the month name. (Codes are below)

At the moment the Hide macro runs when the file opens but
the Protection one is run by click a macro button.

Basically I would like to combine the two so that when a
user opens a file it is protected and the hide macro runs.

Any help will be greatfully appreciated!

Natalie

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="justme"
Next n
Application.ScreenUpdating = True
End Sub



Sub Workbook_Open()

Dim MyMonth As Integer
MyMonth = Month(Now())

Select Case MyMonth

Case 1 'If month number is 1 (Jan)
Sheets("Feb").Visible = False
Sheets("Mar").Visible = False
Case 2 'If Month number is 2 (Feb)
Sheets("Jan").Visible = False
Sheets("March").Visible = False
Case 3 'If Month number is 3 (Mar)
Sheets("Jan").Visible = False
Sheets("Mar").Visible = True
Sheets("Feb").Visible = False
End Select
End Sub


 
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
Combining two macros Colin Hayes Excel Discussion (Misc queries) 2 June 7th 11 02:28 PM
Combining Macros and if function perl Excel Worksheet Functions 2 September 19th 09 03:04 PM
Combining macros aussiegirlone Excel Discussion (Misc queries) 9 June 30th 09 03:14 AM
Combining macros GarToms Excel Discussion (Misc queries) 2 February 9th 06 08:51 AM
Combining 3 macros to 1 David Excel Programming 3 April 16th 04 02:35 PM


All times are GMT +1. The time now is 02:14 AM.

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

About Us

"It's about Microsoft Excel"