I have a spreadsheet which uses a macro to hide different rows depending on the values entered into a cell
The spreadsheet is protected with a password so that password is used in the macro to unprotect the sheet to run the macro and re-protect it when it's finished
However when the sheet is protected I can still click on the sheet tab and select "View Code" which shows the macro with the embedded password in a VBA window. Is there any way of preventing this while the sheet is protected? I need to prevent users being able to see the password and using it to unprotect the sheet which has many conditional formatting and calculations which may get destroyed if overwritten
code is
thanksPrivate Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B2")) Is Nothing Then
Application.EnableEvents = False
Me.Unprotect Password:="andy"
Range("A6:A60").EntireRow.Hidden = False
Select Case Range("B2").Value
Case 999
Case "one"
Range("A15, A22, A24:A26, A28:A41, A58:A69").EntireRow.Hidden = True
Case 100
Range("A15, A22, A26, A37, A40, A58:A69").EntireRow.Hidden = True
Case 101
Range("A15, A22, A24, A26, A37, A40, A58:A69").EntireRow.Hidden = True
End Select
Me.Protect Password:="andy"
Application.EnableEvents = True
End If
End Sub
Bookmarks