raajnabriz
Board Regular
- Joined
- Jun 11, 2014
- Messages
- 112
hi,
i would like to write 2 codes in Private Sub Workbook_Open() as follows [ or rather how to combine them together]
The first code is to force enable macros and the second is message box upon workbook open.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Unhide the Starting Sheet
Sheets("START").Visible = xlSheetVisible
'Step 3: Start looping through all worksheets
For Each ws In ThisWorkbook.Worksheets
'Step 4: Check each worksheet name
If ws.Name <> "START" Then
'Step 5: Hide the sheet
ws.Visible = xlVeryHidden
End If
'Step 6: Loop to next worksheet
Next ws
'Step 7: Save the workbook
ActiveWorkbook.Save
End Sub
Private Sub Workbook_Open()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ThisWorkbook.Worksheets
'Step 3: Unhide All Worksheets
ws.Visible = xlSheetVisible
'Step 4: Loop to next worksheet
Next ws
'Step 5: Hide the Start Sheet
Sheets("START").Visible = xlVeryHidden
End Sub
AND
Code:
Private Sub Workbook_Open()
MsgBox "Created By: RAAJNABRIZ" & vbCrLf & "M. C. Department", vbOKOnly + vbInformation
End Sub
when i use the above codes, it does not work bcoz there are 2 workbook_Open() and if i write both codes in one workbook_Open() it also does not work, please help
any help will be appreciated
i would like to write 2 codes in Private Sub Workbook_Open() as follows [ or rather how to combine them together]
The first code is to force enable macros and the second is message box upon workbook open.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Unhide the Starting Sheet
Sheets("START").Visible = xlSheetVisible
'Step 3: Start looping through all worksheets
For Each ws In ThisWorkbook.Worksheets
'Step 4: Check each worksheet name
If ws.Name <> "START" Then
'Step 5: Hide the sheet
ws.Visible = xlVeryHidden
End If
'Step 6: Loop to next worksheet
Next ws
'Step 7: Save the workbook
ActiveWorkbook.Save
End Sub
Private Sub Workbook_Open()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ThisWorkbook.Worksheets
'Step 3: Unhide All Worksheets
ws.Visible = xlSheetVisible
'Step 4: Loop to next worksheet
Next ws
'Step 5: Hide the Start Sheet
Sheets("START").Visible = xlVeryHidden
End Sub
AND
Code:
Private Sub Workbook_Open()
MsgBox "Created By: RAAJNABRIZ" & vbCrLf & "M. C. Department", vbOKOnly + vbInformation
End Sub
when i use the above codes, it does not work bcoz there are 2 workbook_Open() and if i write both codes in one workbook_Open() it also does not work, please help
any help will be appreciated