Application.ScreenUpdating = False
Sheets("الادخال").Visible = True
Sheets("data1").Visible = True
Sheets("ســـــــولار").Visible = True
Sheets("Diesel Chart").Visible = True
Sheets("كارت الصنف").Visible = True
Sheets("طلبات الاحتياج").Visible = True
Sheets("حمالات و صرفيات").Visible = True
If Sheets("الادخال").Range("m2").Value = "Guest" And Sheets("الادخال").Range("m3").Value = "55555" Then
Sheets("الادخال").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Sheets("كارت الصنف").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.ScreenUpdating = False
Sheets("data1").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.ScreenUpdating = False
Sheets("ســـــــولار").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.ScreenUpdating = False
Sheets("Diesel Chart").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.ScreenUpdating = False
Sheets("حمالات و صرفيات").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.ScreenUpdating = False
Sheets("طلبات الاحتياج").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.ScreenUpdating = False
Sheets("الرئيسيه").Activate
Application.ScreenUpdating = False
End If
If Sheets("الادخال").Range("m2").Value = "A.kandil" And Sheets("الادخال").Range("m3").Value = "4444" Or Sheets("الادخال").Range("m2").Value = "M.sobhi" And Sheets("الادخال").Range("m3").Value = "1234" Then
Sheets("الادخال").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("كارت الصنف").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("data1").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("ســـــــولار").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("Diesel Chart").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("حمالات و صرفيات").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("طلبات الاحتياج").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
Application.ScreenUpdating = False
Sheets("الرئيسيه").Activate
End If
لاحظ اختلاف اسماء الشيتات لديك واختلاف اسماء المستخدمين وكلمات المرور؛
الاكواد التالية توضع فى الحدث BEFORCLOSE فى اليوزرفورم فى زر نعم بنفس الطريقة المشروحة فى الفيديو :