Thank you guys, I really appreciate your comments. I guess I figured out the UserForm1 where the 438 error was after creating a new test workbook.
Now I'm facing another run-time error 1004 - Method "visible" of 'object_worksheet' failed- this is at the actual Workbook where the 2nd macro is applied, the code is:
The error accord after a user saves and try to close the sheet.Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim w As Worksheet Dim bSaveIt As Boolean bSaveIt = False For Each w In Worksheets If w.Visible Then Select Case w.Name Case "Abdi" w.Protect ("u1pass") w.Visible = False ---------> this is where the error is bSaveIt = True Case "Anisa" w.Protect ("u2pass") w.Visible = False ---------> this is where the error is bSaveIt = True End Select End If Next w If bSaveIt Then ActiveWorkbook.CustomDocumentProperties("auth").Delete ActiveWorkbook.Save End If End Sub Private Sub Workbook_Open() UserForm1.Show End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object) If Sh.Name <> "Main" Then If Sh.Name <> ActiveWorkbook.CustomDocumentProperties("auth").Value Then Sh.Visible = False MsgBox "You don't have authorization to view that sheet!" End If End If End Sub





- this is at the actual Workbook where the 2nd macro is applied, the code is:
Reply With Quote
