K0st4din
Well-known Member
- Joined
- Feb 8, 2012
- Messages
- 501
- Office Version
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hi, so far I have used this macro so that when I close the workbook, it can hide the worksheets and leave only Sheet1. This macro is located in ThisWorkbook .
However, since I need to add one more macro, I'm trying to make the two macros fire one after the other in the Module. Ie Call 1st macro and then Call 2nd macro.
The one in ThisWorkbook - I stopped it.
I made a new name with a new Module of the same macro but already as a Sub with new name ().
When I press the button the 1st macro works and the second one gives me an error that in this case I can't use Me.Sheets
I'm asking for some help, why it doesn't want to work and where I'm doing wrong.
Thank you in advance.
However, since I need to add one more macro, I'm trying to make the two macros fire one after the other in the Module. Ie Call 1st macro and then Call 2nd macro.
The one in ThisWorkbook - I stopped it.
I made a new name with a new Module of the same macro but already as a Sub with new name ().
When I press the button the 1st macro works and the second one gives me an error that in this case I can't use Me.Sheets
I'm asking for some help, why it doesn't want to work and where I'm doing wrong.
Thank you in advance.
VBA Code:
'This one is in ThisWorkbook
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oneSheet As Worksheet
Sheet1.Visible = xlSheetVisible
For Each oneSheet In Me.Sheets
If oneSheet.Name <> Sheet1.Name Then
oneSheet.Visible = xlSheetVeryHidden
End If
Next oneSheet
End Sub
VBA Code:
'This one is in new SUB in Module
Sub skrivane_na_sheetove()
Dim oneSheet As Worksheet
Sheet1.Visible = xlSheetVisible
For Each oneSheet In Me.Sheets
If oneSheet.Name <> Sheet1.Name Then
oneSheet.Visible = xlSheetVeryHidden
End If
Next oneSheet
End Sub
VBA Code:
Sub zapazvanefileiskrivanesheetove()
Call btnSaveTheWorkbook_Click 'this one work
Call skrivane_na_sheetove 'This one NO
End Sub