I know this has been asked before, but i cant find an answer for the problem.
I have a spreadsheet that multiple users use and i want to display 1 worksheet that asks the user to "enable the macro". when they do, that page hides and 3 others are shown. This part works ok
when they save the spreadsheet, it saves as normal.
what i want to do is when the user closes the spreadsheet is to rehide the 3 opened worksheets and unhides the original worksheet that asks to "enable the macro". this works fine also when the user presses save when closing. however if they dont want to save when closing, then the worksheet states doesnt change to my desired states and so when the next person opens the sheet, they are not prompted to "enable the macro" due to the 3 worksheets are open and not the single sheet.
i use this vba for the close
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim ws As Worksheet
Application.ScreenUpdating = False
'---------------------------------------
If Sheets("For Mylearning").Visible = True Then
Sheets("For Mylearning").Select
ActiveSheet.Range("$B$2:$J$3002").AutoFilter Field:=9, Criteria1:="="
Sheets("Placement Date").Select
End If
'---------------------------------------
If Sheets("Landing Page").Visible = True Then
Sheets("Placement Date").Visible = True
Sheets("IT Service Desk").Visible = True
Sheets("For Mylearning").Visible = True
Sheets("For Mylearning").Select
ActiveSheet.Range("$B$2:$J$3002").AutoFilter Field:=9, Criteria1:="="
Sheets("Landing Page").Visible = True
Sheets("Landing Page").Select
Sheets("Placement Date").Visible = xlSheetVeryHidden
Sheets("IT Service Desk").Visible = xlSheetVeryHidden
Sheets("For Mylearning").Visible = xlSheetVeryHidden
End If
'---------------------------------------
Application.Run "SendEmailOnSave"
Application.ScreenUpdating = True
End Sub
and use this vba for the exit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("For Mylearning").Select
ActiveSheet.Range("$B$2:$J$3002").AutoFilter Field:=9, Criteria1:="="
Sheets("Placement Date").Activate
ThisWorkbook.Sheets("Landing Page").Visible = True
Sheets("Landing Page").Select
ThisWorkbook.Sheets("Placement Date").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("IT Service Desk").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("For Mylearning").Visible = xlSheetVeryHidden
End Sub
if they chose yes, save my changes when they close it all works good, but if they choose No then im a little screwed.
is there a vba that if they choose no to the changes that removes all the changes they did make (since last save) and save it anyway?
Bookmarks