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

كيفية نسخ حدود النطاق المحدد فقط في Excel؟

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

انسخ حدود النطاق المحدد فقط برمز VBA


انسخ حدود النطاق المحدد فقط برمز VBA

يمكن أن تساعدك التعليمات البرمجية لـ VBA التالية في نسخ نمط الحدود للخلايا المحددة فقط ، ثم تطبيق نمط الحدود هذا على نطاق جديد في Excel. الرجاء القيام بما يلي.

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

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات الإطار، انقر فوق إدراج > وحدة، ثم انسخ والصق رمز فبا أدناه في نافذة التعليمات البرمجية.

رمز فبا: انسخ حدود النطاق المحدد فقط في Excel

Sub CopyBorders()
'Updated by Extendoffice 20211203
    Dim xRg, yRg As Range
    On Error Resume Next
    
    Set xRg = Application.InputBox("Select Range with Borders to Copy...", "Kutools For Excel", , , , , , 8)
    Set yRg = Application.InputBox("Select Cell to Apply Borders to range..", "Kutools For Excel", , , , , , 8)
    
    
    With yRg.Borders(xlEdgeLeft)
        .LineStyle = xRg.Borders(xlEdgeLeft).LineStyle
        .ColorIndex = xRg.Borders(xlEdgeLeft).ColorIndex
        .TintAndShade = xRg.Borders(xlEdgeLeft).TintAndShade
        .Weight = xRg.Borders(xlEdgeLeft).Weight

    End With
    With yRg.Borders(xlEdgeTop)
        .LineStyle = xRg.Borders(xlEdgeTop).LineStyle
        .ColorIndex = xRg.Borders(xlEdgeTop).ColorIndex
        .TintAndShade = xRg.Borders(xlEdgeTop).TintAndShade
        .Weight = xRg.Borders(xlEdgeTop).Weight
    End With
    With yRg.Borders(xlEdgeBottom)
        .LineStyle = xRg.Borders(xlEdgeBottom).LineStyle
        .ColorIndex = xRg.Borders(xlEdgeBottom).ColorIndex
        .TintAndShade = xRg.Borders(xlEdgeBottom).TintAndShade
        .Weight = xRg.Borders(xlEdgeBottom).Weight
    End With
    With yRg.Borders(xlEdgeRight)
        .LineStyle = xRg.Borders(xlEdgeRight).LineStyle
        .ColorIndex = xRg.Borders(xlEdgeRight).ColorIndex
        .TintAndShade = xRg.Borders(xlEdgeRight).TintAndShade
        .Weight = xRg.Borders(xlEdgeRight).Weight
    End With

    With yRg.Borders(xlInsideHorizontal)
        .LineStyle = xRg.Borders(xlInsideHorizontal).LineStyle
        .ColorIndex = xRg.Borders(xlInsideHorizontal).ColorIndex
        .TintAndShade = xRg.Borders(xlInsideHorizontal).TintAndShade
        .Weight = xRg.Borders(xlInsideHorizontal).Weight
    End With
    With yRg.Borders(xlInsideVertical)
        .LineStyle = xRg.Borders(xlInsideVertical).LineStyle
        .ColorIndex = xRg.Borders(xlInsideVertical).ColorIndex
        .TintAndShade = xRg.Borders(xlInsideVertical).TintAndShade
        .Weight = xRg.Borders(xlInsideVertical).Weight
    End With
End Sub

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

4. في الثانية كوتولس ل إكسيل مربع الحوار ، يرجى تحديد خلية لتطبيق الحدود المنسوخة ، ثم انقر فوق OK زر. انظر لقطة الشاشة:

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


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

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

🤖 مساعد 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 (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hola me gusto mucho al macro para copiar los Bordes, pero al copiar los bordes me borra el formato que tienen las celtas es decir borra colores y otros formatos que ya tiene la celda. me puedes ayudar con una macro que me permita copiar los bordes de otra celta a otra sin borrar el formato que tiene la celda de destino?
This comment was minimized by the moderator on the site
Dobrý den,

Děkuji za pomoc s kopírováním pouze ohraničení.
Šlo by
Děkuji.
Jirka
This comment was minimized by the moderator on the site
The code also copied my numeric formats and overwrote those in the target cells. Perhaps I did something wrong?
This comment was minimized by the moderator on the site
Hi David,
In my case, the code only copy the borders into the target cells. Can you tell me your Excel version? Thank you for your comment.
This comment was minimized by the moderator on the site
Hello crystal,
I know this is over a year later, but due to a rehosting of my e-mail system, your question rose to the top of my inbox.
My Excel version is 2016 16.0.4993.1001 as reported by Account>About
This comment was minimized by the moderator on the site
Hi David,
Glad to receive your reply. I have tested the code in my Excel 2016, but it still copy the border only. Do you mind sending a copy of your data to ? Sorry for the inconvenience.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations