مشاركة عبر


كيفية القيام بما يلي: تغيير التنسيق في صفوف ورقة عمل متضمنة لخلايا محددة

ينطبق على

تنطبق المعلومات الموجودة في هذا الموضوع فقط على أنواع المشاريع وإصدارات Microsoft Office التالية: لمزيد من المعلومات، راجع الميزات المتوفرة بواسطة تطبيقات Office و نوع المشروع.

نوع المشروع

  • مشروعات على مستوى المستند

  • مشروعات على مستوى التطبيق

إصدار Microsoft Office

  • Excel 2007

  • Excel 2010

يمكنك تغيير خط صف بأكمله يحتوي على خلية محددة بحيث يكون النص غامقاً.

لجعل الصف الحالي غامقاً و الصف المغمق مسبقاً عادياً

  1. قم بالتصريح بمتغير ثابت للتمكن من تعقّب الصف المحدد مسبقاً.

    Static previousRow As Integer = 0
    
    static int previousRow = 0;
    
  2. قم باسترداد مرجع للخلية الحالية باستخدام الخاصية ActiveCell .

    Dim currentCell As Excel.Range = Me.Application.ActiveCell
    
    Excel.Range currentCell = this.Application.ActiveCell;
    
  3. اجعل نمط الصف الحالي الغامق باستخدام الخاصية EntireRow للخلية النشطة.

    currentCell.EntireRow.Font.Bold = True
    
    currentCell.EntireRow.Font.Bold = true; 
    
  4. في previousRow، إنشاء Outlook إضافة-في مشروع يحمل الاسم MapItإضافةIn. في صندوق الحوار إضافة عنصر جديد?، تحديد منطقة النموذج Outlook ، اسم ملف MapIt، وثم انقر فوق إضافة.

    If previousRow <> 0 Then
    
    if (previousRow != 0)
    
  5. تأكد من أن الصف الحالي يختلف عن الصف السابق.

    If currentCell.Row <> previousRow Then
    
    if (currentCell.Row != previousRow)
    
  6. قم باسترداد مرجع لنطاق يمثل الصف الذي تم تحديده مسبقاً ، ثم قم بتعيين هذا الصف ليكون غير غامق.

    Dim rng As Excel.Range = DirectCast(ws.Rows(previousRow), Excel.Range)
    rng.EntireRow.Font.Bold = False
    
    Excel.Range rng = (Excel.Range)ws.Rows[previousRow, missing];
    rng.EntireRow.Font.Bold = false;
    
  7. قم بتخزين الصف الحالي بحيث يصبح الصف السابق على المسار التالي.

    previousRow = currentCell.Row
    
    previousRow = currentCell.Row;
    

يوضح المثال التالي الأسلوب الكامل.

مثال

Private Sub BoldCurrentRow(ByVal ws As Excel.Worksheet)

    ' Keep track of the previously bolded row.
    Static previousRow As Integer = 0

    ' Work with the current active cell.
    Dim currentCell As Excel.Range = Me.Application.ActiveCell

    ' Bold the current row.
    currentCell.EntireRow.Font.Bold = True

    ' If a pass has been done previously, make the old row not bold.
    ' Make sure previousRow is not 0 (otherwise this is your first pass through).
    If previousRow <> 0 Then

        ' Make sure the current row is not the same as the previous row.
        If currentCell.Row <> previousRow Then

            Dim rng As Excel.Range = DirectCast(ws.Rows(previousRow), Excel.Range)
            rng.EntireRow.Font.Bold = False
        End If
    End If

    ' Store the new row number for the next pass.
    previousRow = currentCell.Row
End Sub
// Keep track of the previously bolded row.
static int previousRow = 0;

private void BoldCurrentRow(Excel.Worksheet ws)
{
    // Work with the current active cell.
    Excel.Range currentCell = this.Application.ActiveCell;

    // Bold the current row.
    currentCell.EntireRow.Font.Bold = true; 

    // If a pass has been done previously, make the old row not bold.
    // Make sure previousRow is not 0 (otherwise this is your first pass through).
    if (previousRow != 0)

        // Make sure the current row is not the same as the previous row.
        if (currentCell.Row != previousRow)
        {
            Excel.Range rng = (Excel.Range)ws.Rows[previousRow, missing];
            rng.EntireRow.Font.Bold = false;
        }

    // Store the new row number for the next pass.
    previousRow = currentCell.Row;
}

راجع أيضًا:

المهام

كيفية القيام بما يلي: تطبيق أنماط إلى نطاقات في مصنفات

كيفية القيام بما يلي: نسخ البيانات و تنسيقها عبر أوراق العمل

المبادئ

العمل على أوراق العمل

المعلمات الاختيارية في حلول Office