اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

اتمنى المساعدة حول كود خاص شيك بوكس


ibra9
إذهب إلى أفضل إجابة Solved by lionheart,

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

احتاج كود بوجود 3 شيك بوكس في نفس السطر عند اختيار واحد منهم يتكنسل من الاثنين الباقيين تلقائيا والعكس بالنسبة للباقيين الثاني والثالث أيضا 

علما أنا عوز يكون شيك بوكس ولا أريد شيك بوتون

شكرا جزيلا أ/ محمد صالح على ردك 

عندي هذا الكود البسيط ولكن في الملف المرفق يعمل على كل شيك بوكس على حده .. ولكن احتاج لكود بحيث يكون على 3 شيك بوكس في كود واحد

Sub CheckBox1_Click()
If Range("e9").Value = True Then
Range("f9").Value = False
End If
End Sub
Sub CheckBox2_Click()
If Range("f9").Value = True Then
Range("e11").Value = False
End If
End Sub

ورقة عمل Microsoft Excel جديد __.xlsx

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

أخي الكريم

من أساسيات البرمجة :

* في حالة اختيار المستخدم لبديل واحد فقط يتم استخدام option button 

* في حالة اختيار المستخدم لأكثر من بديل نستخدم check box

بوضوح أكثر:

في مثل حالتك هذه يجب استخدام option button

لأنك في الأخير تريد أن يكون عنصر واحد فقط هو المحدد

بالتوفيق 

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

  • أفضل إجابة

There are no events for the check boxes on form controls, but there is a workaround

In standard module put the code

Sub CheckBoxFormControl()
    Dim ws As Worksheet, cb As Shape, sChk As String, r As Long, c As Long
    Set ws = ActiveSheet
    With ws.CheckBoxes(Application.Caller)
        sChk = .Name
        r = .TopLeftCell.Row
        c = .TopLeftCell.Column
    End With
    If ws.CheckBoxes(Application.Caller).Value = 1 Then
        For Each cb In ws.Shapes
            If cb.Type = msoFormControl Then
                If cb.FormControlType = xlCheckBox And cb.Name <> sChk Then
                    If cb.TopLeftCell.Row = r And cb.TopLeftCell.Column = c Then
                        If cb.ControlFormat.Value = 1 Then cb.ControlFormat.Value = -4146
                    End If
                End If
            End If
        Next cb
    End If
End Sub

 

Now select only one check box then press Ctrl + A to select all the check boxes on the worksheet then right click and assign macro [CheckBoxFormControl] 

The code will loop through each check box in the same row only and uncheck any other check boxes except the one triggered by Application.Caller

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

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