Range Property
أشهر الخصائص لكائن النطاق
- ColumnWidth
- WrapText
- End
- Font
- FormulaArray
- RowHeight
- Value
- NumberFormat
- Borders
Range.ColumnWidth property
خاصية التحكم فى عرض الأعمدة
'https://elshriefacademy.blogspot.com
Range("A:A,C:C").ColumnWidth = 25
سوف يتم زيادة عرض العمودين (A و C ) فقط .
Range.WrapText property
التفاف النص
'https://elshriefacademy.blogspot.com
Range("A1").WrapText =True
Range.End property
الذهاب إلى آخر خلية بالنطاق المحدد حسب الإتجاه الذى ستحدده
Syntax
(expression. End(Direction
Expression التعبيرقد يكون النطاق أو متغير يمثل النطاق .
End الخاصية .
Direction الاتجاه المطلوب التوجه إليه ، وله تعداد خاص به XlDirection
enumeration أربعة إتجاهات وكل إتجاه له قيمة يمكنك إستخدامها ، وهم كالتالي :
Name | Value | Direction |
---|---|---|
xlDown | 4121- | Down |
xlToLeft | 4159- | To Left |
xlToRight | 4161- | To Right |
xlUp | 4162- | Up |
Range.Font property
الخط (Name ، FontStyle، Size ، Underline ، Color ، Effects)
'https://elshriefacademy.blogspot.com
Range("A1:A5").Font.Name = "Calibri"
استخدام الـ Font.FontStyle
'https://elshriefacademy.blogspot.com
Range("A1:A5").Font.FontStyle = "Italic"
استخدام الـ Font.Size
يمكن تعيين قيمة هذه الخاصية إلى قيمة عدد صحيح من 1 إلى 409.
'https://elshriefacademy.blogspot.com
Range("A1:A5").Font.Size = 14
استخدام الـ Font.Underline
'https://elshriefacademy.blogspot.com
Range("A1").Font.Underline = xlUnderlineStyleDouble
استخدام الـ Font.Color
'https://elshriefacademy.blogspot.com
Range("A1").Font.Color = vbBlack
استخدام الـ Effects
وتأخذ قيمة منطقية True
'https://elshriefacademy.blogspot.com
Range("A1").Font.Strikethrough =True
Range.FormulaArray property
الصيغ (المعادلات)
'https://elshriefacademy.blogspot.com
Range("A1:C5").FormulaArray = "=3"
'-----------------------
Range("E1:E3").FormulaArray = "=Sum(F1:F3)"
Range.RowHeight property
ارتفاع الصف
'https://elshriefacademy.blogspot.com
Range("B6:B6").RowHeight = 40
'https://elshriefacademy.blogspot.com
Range("B6:B6,D8:D8").RowHeight = 40
Range.Value property
ادخال القيم
'https://elshriefacademy.blogspot.com
Range("A1").Value = 5
'-----------------------
Range("A2").Value = "VBA"
Range.NumberFormat property
'https://elshriefacademy.blogspot.com
Range("D1").NumberFormat = "General" 'General
'-----------------------
Range("D2").NumberFormat = "0.00" 'Number
'-----------------------
Range("D3").NumberFormat = "$#,##0.00" 'Currency
'-----------------------
Range("D4").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)" 'Accounting
'-----------------------
Range("D5").NumberFormat = "yyyy-mm-dd;@" 'Date
'-----------------------
Range("D6") = Format(Now(), "dd/mm/yyyy") 'Date
'-----------------------
Range("D7") = Format(Now(), "dd-mm-yy") 'Date
'-----------------------
Range("D8") = Format(Now(), "dd-mm") 'Date
'-----------------------
Range("D9") = Format(Now(), "mm-yy") 'Date
'-----------------------
Range("D10").NumberFormat = "h:mm:ss AM/PM;@" 'Time
'-----------------------
Range("D11") = Format(Now(), "hh:mm AM/PM") 'Time
'-----------------------
Range("D12") = Format(Now(), "hh:mm:ss AM/PM") 'Time
'-----------------------
Range("D13") = Format(Now(), "hh:mm") 'Time
'-----------------------
Range("D14") = Format(Now(), "dd/mm/yyyy hh:mm") ' Date + Time
'-----------------------
Range("D15").NumberFormat = "0.00%" 'Percentage
'-----------------------
Range("D16").NumberFormat = "# ?/?" 'Fraction
'-----------------------
Range("D17").NumberFormat = "0.00E+00" 'Scientific
'-----------------------
Range("D18").NumberFormat = " Text" 'Text
'-----------------------
Range("D19").NumberFormat = "00000" 'Special
'-----------------------
Range("D20").NumberFormat = "$#,##0.00_);[Red]($#,##0.00)" 'Custom
Range.Borders property
انشاء الحدود المختلفة للنطاقات والخلايا
xlDiagonalUp يتم تشغيل الحدود من الزاوية السفلية اليسرى إلى أعلى يمين كل خلية في النطاق.
xlEdgeBottom الحدود في أسفل النطاق.
xlEdgeLeft الحدود عند الحافة اليسرى للنطاق.
xlEdgeRight الحدود عند الحافة اليمنى للنطاق.
xlEdgeTop الحدود في أعلى النطاق.
xlInsideHorizontal حدود أفقية لكافة الخلايا في النطاق باستثناء الحدود الموجودة خارج النطاق.
xlInsideVertical الحدود الرأسية لكافة الخلايا في النطاق باستثناء الحدود على خارج النطاق.
يجب أن تقوم بتعيين كل خاصية من الخصائص الخاصة بالحدود الى أى من
( Line Style,or Color,or ..etc )
xlDashDot مزيج من الشرط والنقط.
xlDashDotDot مزيج من الشرط وبينهم نقطتين.
xlDot خط مكون من نقط.
xlDouble خط مزدوج.
xlLineStyleNone بدون خط.
xlSlantDashDot شرط مائلة.
لإزالة الحدود
Line Style
xlContinuous خط مستمر.
xlDash خط متقطع.xlDashDot مزيج من الشرط والنقط.
xlDashDotDot مزيج من الشرط وبينهم نقطتين.
xlDot خط مكون من نقط.
xlDouble خط مزدوج.
xlLineStyleNone بدون خط.
xlSlantDashDot شرط مائلة.
'https://elshriefacademy.blogspot.com
Range("C2").Borders(xlEdgeBottom).LineStyle = xlContinuous
لإزالة الحدود
'https://elshriefacademy.blogspot.com
Range("C2").Borders(xlEdgeBottom).LineStyle = xlNone