يوجد مشكلة عند التطبيق
ما الخطأ فى الكود
مع العلم ان كلمة المرور هى _{A#_f^z5Pr8
والمرقة المراد التطبيق عليه اسمها Ali_1
CODE
Sub Create_Hidden_Named_Range_If_Not_Exists()
Dim sPass As String
sPass = "Sheet1Pass|_{A#_f^z5Pr8'}"
If Not IsError(Evaluate(Split(sPass, "|")(0))) Then
MsgBox "Named Range Exists", vbExclamation
Else
ThisWorkbook.Names.Add Name:=Split(sPass, "|")(0), RefersToR1C1:=Split(sPass, "|")(1), Visible:=False
End If
End Sub
Sub Check_If_Worksheet_Password_Changed_By_Hidden_Named_Range()
Dim ws As Worksheet, sPass As String
Set ws = ThisWorkbook.Worksheets("Ali_1")
sPass = Mid(ThisWorkbook.Names("Sheet1Pass").Value, 2)
If ws.ProtectContents = True Then
On Error Resume Next
ws.Unprotect sPass
If Err <> 0 Then
MsgBox "Password Changed For The Worksheet: " & ws.Name, vbExclamation: Err = 0
Else
ws.Protect sPass
MsgBox "Congratulations! No Change In Worksheet: " & ws.Name, vbInformation
End If
Else
MsgBox "No Password For The Worksheet: " & ws.Name, vbExclamation
End If
End Sub