انتقل إلى المحتوى الرئيسي

كيفية توسيط مربع الاختيار تلقائيًا في الخلية في إكسيل؟

أثناء إدراج مربعات الاختيار في الخلايا في Excel ، قد تلاحظ أنه من الصعب ترتيب جميع مربعات الاختيار بشكل منظم كما هو موضح في لقطة الشاشة اليسرى. في الواقع ، يمكنك نقل جميع خانات الاختيار إلى مركز الخلية للحفاظ على ترتيبها بدقة. الطريقة في هذه المقالة يمكن أن تساعدك.

مربع الاختيار التوسيط التلقائي في الخلية برمز VBA


مربع الاختيار التوسيط التلقائي في الخلية برمز VBA

لتوسيط جميع مربعات الاختيار تلقائيًا في الخلايا في ورقة العمل الحالية ، يرجى القيام بما يلي.

1. في ورقة العمل ، تحتاج إلى توسيط جميع مربعات الاختيار تلقائيًا ، اضغط على قديم + F11 مفاتيح لفتح ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، الرجاء الضغط إدراج > وحدة. ثم انسخ والصق كود فبا في نافذة الكود.

رمز فبا: مركز جميع مربعات الاختيار في الخلايا تلقائيًا

Sub CenterCheckbox ()
    Dim xRg As Range
    Dim chkBox As OLEObject
    Dim chkFBox As CheckBox
    On Error Resume Next
    Application.ScreenUpdating = False
    For Each chkBox In ActiveSheet.OLEObjects
        If TypeName(chkBox.Object) = "CheckBox" Then
            Set xRg = chkBox.TopLeftCell
            chkBox.Width = xRg.Width * 2 / 3
            chkBox.Height = xRg.Height
            chkBox.Left = xRg.Left + (xRg.Width - chkBox.Width) / 2
            chkBox.Top = xRg.Top + (xRg.Height - chkBox.Height) / 2
        End If
    Next
    For Each chkFBox In ActiveSheet.CheckBoxes
        Set xRg = chkFBox.TopLeftCell
        chkFBox.Width = xRg.Width * 2 / 3
        chkFBox.Height = xRg.Height
        chkFBox.Left = xRg.Left + (xRg.Width - chkFBox.Width) / 2
        chkFBox.Top = xRg.Top + (xRg.Height - chkFBox.Height) / 2
    Next
    Application.ScreenUpdating = True
End Sub

3. اضغط على F5 مفتاح. ثم يتم نقل جميع مربعات الاختيار إلى وسط الخلايا على الفور كما هو موضح أدناه.

ملاحظات: يمكن تطبيق رمز VBA هذا على كل من CheckBox (عنصر تحكم ActiveX) و CheckBox (عنصر تحكم النموذج).

تلميح: إذا كنت تريد إدراج خانات اختيار متعددة في نطاق محدد بشكل مجمّع ، فيمكنك تجربة مربعات اختيار إدراج دفعة فائدة pf كوتولس ل إكسيل. أو إدراج عدة أزرار خيارات مع ملف أزرار الخيار إدراج دفعة خدمة. بالإضافة إلى ذلك ، يمكنك حذف جميع خانات الاختيار مرة واحدة بامتداد خانات اختيار الحذف الدفعي فائدة على النحو المبين أدناه لقطات الشاشة. يمكنك الذهاب إلى قم بتنزيل البرنامج مجانًا دون أي قيود خلال 30 يومًا.


مقالات ذات صلة:

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و Visio والمشروع.
  • فتح وإنشاء مستندات متعددة في علامات تبويب جديدة من نفس النافذة ، بدلاً من النوافذ الجديدة.
  • يزيد من إنتاجيتك بنسبة 50٪ ، ويقلل مئات النقرات بالماوس كل يوم!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The VBA does not work at all for me. When I press F5, it appears that the module runs, but the checkboxes did not move.
This comment was minimized by the moderator on the site
After some more experimenting, I figured out that the VBA does work for manually inserted checkboxes, but if I use Kutools batch insert, it does not. How do I center all the checkboxes inserted with Kutools?
This comment was minimized by the moderator on the site
Hi quadma,
The code also works for the checkboxes inserted by Kutools. Which Excel version are you using?
This comment was minimized by the moderator on the site
I'm using office 360. I think the issue that I'm having is that when I use the Kutools batch insert, the size of the the checkbox object is as wide as the column that it's inserted into (i.e. the checkbox object width is greater than it's height), with the visible checkbox itself on being left justified within the object. If I select all the checkbox objects and then resize them so that the height and length are equal, and then run the VBA, it does then center the checkboxes within the column.





This seems like an unnecessary step, given that checkboxes are square, why is Kultools not making the checkbox objects square?
This comment was minimized by the moderator on the site
Hi quadma,
The check boxes inserted by Kutools are the same as the Check Box (Form Control) which inserted by Excel.
I don't really understand you said "making the checkbox object square". Normally a check box include the box field and the value field. Kutools keeps the check boxes' value empty if the selected cells are blank. And if there are values in selected cells, the cell value will be taken as the check box value.
This comment was minimized by the moderator on the site
I've uploaded a picture to show what I mean. Hopefully that helps.
This comment was minimized by the moderator on the site
Hi quadma, I got your point. We will think about it and thank you for your patience.
This comment was minimized by the moderator on the site
This worked great for me except it doesn't align it with the text in the next cell which is bottom aligned. Is there a way to align the checkboxes for bottom aligned in order to get them to align with the text in the next cell? Thanks!
This comment was minimized by the moderator on the site
You VDA script is partly working. Because when i applied it, linked cell next to Checkbox get changed and got linked with a cell under it.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations