So, I'm having an issue and from the research I've done, I don't think there is solution but I will pose the question to the experts here!
I have a workbook that I have password protected each sheet. I also have the code below integrated on one sheet that triggers a name change and color change on the pw protected tab. However, when I protect the workbook structure (which I need to do so the order the tabs cannot be changed), this prevents me from executing the code because the workbook structure is protected.
I am wondering if there is a work-around to unprotect the workbook structure, execute the code below, then password protect the sheet and password protect the workbook structure once again. Thoughts?
Any help is greatly appreciated!
I have a workbook that I have password protected each sheet. I also have the code below integrated on one sheet that triggers a name change and color change on the pw protected tab. However, when I protect the workbook structure (which I need to do so the order the tabs cannot be changed), this prevents me from executing the code because the workbook structure is protected.
I am wondering if there is a work-around to unprotect the workbook structure, execute the code below, then password protect the sheet and password protect the workbook structure once again. Thoughts?
Any help is greatly appreciated!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Dim ans As Long
On Error GoTo M
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Row > 15 Then
ans = Target.Row
If Target.Value = "Vacant" Or Target.Value = "vacant" Then
Sheets(ans + 1).Tab.Color = RGB(255, 76, 76)
Sheets(ans + 1).Name = Sheets(ans + 1).Cells(5, 3).Value
Else
Sheets(ans + 1).Tab.Color = RGB(255, 248, 66)
Sheets(ans + 1).Name = Target.Value
End If
End If
End If
Exit Sub
M:
MsgBox "Error: Duplicate Tenant Name"
End Sub