اذهب الي المحتوي
أوفيسنا

طلب ماكرو لمنع الكتابة في خلية


الردود الموصى بها

السلام عليكم اخواني أرجو منكم افادتي 
لدي ملف به  خلية أريد أن تصبح ممنوعةمن الكتابة حسب قيمة الخلية التي قبلها لما تكون أكبر أو تساوي 10

الطلب موضح في الملف المرفق 

Demand Macro.rar

رابط هذا التعليق
شارك

جرب هذا الملف

الماكرو مرفق

 

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column <> 2 Or Target.Row < 2 Or Target.Cells.Count > 1 Then
Application.EnableEvents = True: Exit Sub
End If
ActiveSheet.Unprotect
    Cells(Target.Row, 3).Locked = False
       If IsNumeric(Target) And Target >= 10 Then
  Cells(Target.Row, 3).Locked = True
            ActiveSheet.Protect
      End If
Application.EnableEvents = True
End Sub

 

Demand Macro_salim.rar

رابط هذا التعليق
شارك

منذ ساعه, سليم حاصبيا said:

جرب هذا الملف

الماكرو مرفق

 


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column <> 2 Or Target.Row < 2 Or Target.Cells.Count > 1 Then
Application.EnableEvents = True: Exit Sub
End If
ActiveSheet.Unprotect
    Cells(Target.Row, 3).Locked = False
       If IsNumeric(Target) And Target >= 10 Then
  Cells(Target.Row, 3).Locked = True
            ActiveSheet.Protect
      End If
Application.EnableEvents = True
End Sub

 

Demand Macro_salim.rar

تم التعديل باضافة سطر واحد علة الكود

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column <> 2 Or Target.Row < 2 Or Target.Cells.Count > 1 Then
Application.EnableEvents = True: Exit Sub
End If
ActiveSheet.Unprotect
    Cells(Target.Row, 3).Locked = False
       If IsNumeric(Target) And Target >= 10 Then
       Cells(Target.Row, 3) = ""
       Cells(Target.Row, 3).Locked = True
            ActiveSheet.Protect
      End If
Application.EnableEvents = True
End Sub

 

رابط هذا التعليق
شارك

8 ساعات مضت, المسلم العربي said:

شكرا لك سيدي و اخر سؤال كيف اطبق هذه العملية على اعمدة مختلفة و شكرا جزيلا

حدد اي اعمدة تريد العمل عليها

رابط هذا التعليق
شارك

15 ساعات مضت, المسلم العربي said:

شكرا لك سيدي و اخر سؤال كيف اطبق هذه العملية على اعمدة مختلفة و شكرا جزيلا

حدد اي اعمدة تريد العمل عليها

الكود المطلوب

6 دقائق مضت, سليم حاصبيا said:

حدد اي اعمدة تريد العمل عليها

الكود المطلوب


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column < 7 Or Target.Column > 29 _
Or Target.Row < 2 Or Target.Cells.Count > 1 _
Or Target.Column Mod 2 = 0 Then
Application.EnableEvents = True: Exit Sub
End If
ActiveSheet.Unprotect
    Cells(Target.Row, Target.Column + 1).Locked = False
       If IsNumeric(Target) And Target >= 10 Then
       Cells(Target.Row, Target.Column + 1) = ""
       Cells(Target.Row, Target.Column + 1).Locked = True
            ActiveSheet.Protect
      End If
Application.EnableEvents = True
End Sub

 

 

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information