'Global Variable to hold last sheet selected
Public lastSheet As Object
Public PrevActiveCell As Range
Dim CurActiveCell As Range
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Set PrevActiveCell = CurActiveCell
Set CurActiveCell = ActiveCell
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveWindow.Zoom = 100
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Set lastSheet = Sh
End Sub
Private Sub Workbook_Open()
MsgBox "If the scroll bars lock (i.e., you can't move around the worksheet via your keyboard), 'Unfreeze Panes' in the 'View' tab - the panes will automatically re-freeze when you start to work." & vbNewLine & " " & vbNewLine & "When hiding columns, make sure you first select a cell in the column you want to hide. If you do not, it may hide a different column!" & vbNewLine & " " & vbNewLine & "Please also note that the fill handle has been disabled in this workbook to protect the integrety of formulas and formatting. And you will only be able to paste values (ctrl v)." & vbNewLine & " " & vbNewLine & "Read the instructions for more helpful hints and tips." & vbNewLine & " " & vbNewLine & "Please take care when working with data to make sure that it is correct - data management is everyone's responsibility!" & vbNewLine & " " & vbNewLine & "Thank you!", vbOKOnly + vbExclamation, "Workbook etiquette"
Worksheets("Please Note!").Activate
Worksheets("Sheet1").Columns("A:EN").Hidden = False
Dim wks As Worksheet
Dim MyPassword As String
MyPassword = "PASSWORD"
For Each wks In Worksheets
If wks.FilterMode = True Then
wks.Unprotect password:=MyPassword
wks.ShowAllData
wks.Protect password:=MyPassword, AllowFiltering:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True
End If
Next wks
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Sheet1").Columns("A:EN").Hidden = False
Dim wks As Worksheet
Dim MyPassword As String
MyPassword = "PASSWORD"
For Each wks In Worksheets
If wks.FilterMode = True Then
wks.Unprotect password:=MyPassword
wks.ShowAllData
wks.Protect password:=MyPassword, AllowFiltering:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True
End If
Next wks
End Sub
Sub FindLastCell()
Dim LastRow As Long
Dim LastColumn As Long
LastRow = Cells(Rows.Count, 1).End(c1Up).Row
LastColumn = Cells(1, Columns.Count).End(x1ToLeft).Column
End Sub