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

كود تلوين أطر الخلايا


إذهب إلى أفضل إجابة Solved by أبومروان,

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

Sub colorCells()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim lastColumn As Long
    Dim i As Long
    Dim j As Long
    
    Set ws = ActiveSheet ' تعيين الصفحة المفتوحة كـ ws
    
    ' تحديد عدد الصفوف والأعمدة في الصفحة
    lastRow = ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    lastColumn = ws.Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    
    ' تكرار الصفوف والأعمدة وتحديد اللون الذي تريده لكل خلية
    For i = 1 To lastRow
        For j = 1 To lastColumn
            Select Case j ' يمكنك تغيير هذه الأرقام والألوان لتناسب احتياجاتك
                Case 1
                    ws.Cells(i, j).Borders.LineStyle = xlContinuous
                    ws.Cells(i, j).Borders.Color = RGB(255, 0, 0) ' اللون الأحمر
                Case 2
                    ws.Cells(i, j).Borders.LineStyle = xlContinuous
                    ws.Cells(i, j).Borders.Color = RGB(255, 255, 0) ' اللون الأصفر
                Case 3
                    ws.Cells(i, j).Borders.LineStyle = xlContinuous
                    ws.Cells(i, j).Borders.Color = RGB(0, 255, 0) ' اللون الأخضر
                Case 4
                    ws.Cells(i, j).Borders.LineStyle = xlContinuous
                    ws.Cells(i, j).Borders.Color = RGB(0, 0, 255) ' اللون الأزرق
                Case 5
                    ws.Cells(i, j).Borders.LineStyle = xlContinuous
                    ws.Cells(i, j).Borders.Color = RGB(255, 0, 255) ' اللون الأرجواني
                Case 6
                    ws.Cells(i, j).Borders.LineStyle = xlContinuous
                    ws.Cells(i, j).Borders.Color = RGB(0, 255, 255) ' اللون الأزرق الفاتح
            End Select
        Next j
    Next i
End Sub

 

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

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