Border Line Styles - Property
Private Sub CommandButton1_Click()
Range("A3").Borders.Weight = xlThick
Range("A5").Borders.LineStyle = xlDouble
Range("A7").Borders.LineStyle = xlDashDotDot
End Sub
BorderAround Method
Private Sub CommandButton1_Click()
Range("A1:A11").Value = "Sriguranjani"
Columns(1).AutoFit
Range("A1:A11").BorderAround (1)
End Sub
Borderaround Styles
Sub Boarders_Alignments()
Dim sh2 As Worksheet
Set sh2 = ThisWorkbook.Sheets("Sheet2")
sh2.Activate
ActiveWindow.DisplayGridlines = False
sh2.UsedRange.Clear
Range("A1:A5").Value = "Sriguranjani"
Columns(1).AutoFit
Range("A1:A5").BorderAround (1), xlThick, 3
Range("C1:C5").BorderAround (2), xlMedium, 56
Range("E1:E5").BorderAround (4), xlThick, 29
Range("G1:G5").BorderAround (6), xlMedium, 9
Range("E7:E12").BorderAround (9), xlThick, 49
End Sub
Formatting Numeric Values
Number Formatting
Sub removedecimals()
Range("D4").Select
Selection.NumberFormat = "0.0000"
Selection.NumberFormat = "0.000"
Selection.NumberFormat = "0.00"
Selection.NumberFormat = "0.0"
Selection.NumberFormat = "0"
Range("D5").Select
Selection.NumberFormat = "0.000"
Selection.NumberFormat = "0.00"
Selection.NumberFormat = "0.0"
Selection.NumberFormat = "0"
End Sub
State about Horizontal alignment Properties
Private Sub CommandButton1_Click()
Range("A1:H11").Select
Selection.Value = "Pavan"
Selection.HorizontalAlignment = xlCenter
Selection.HorizontalAlignment = xlRight
Selection.HorizontalAlignment = xlLeft
End Sub
State about vertical alignment Properties
Private Sub CommandButton1_Click()
With Range("A1:A11")
.Value = "Pavan"
.VerticalAlignment = xlCenter
.VerticalAlignment = xlTop
.VerticalAlignment = xlBottom
.VerticalAlignment = xlJustify
End With
End Sub
State about Fill_xlDistributed_xlCenterAcrossSelection
Private Sub CommandButton1_Click()
Range("A1:H1").Select
Selection.Value = "Hi Pavan How are you?"
Range("A1:H1").HorizontalAlignment = xlFill
'to provide the space between the words
Range("A1:H1").HorizontalAlignment = xlDistributed
Range("C8").Select
Selection.Value = "hi Pavan"
Range("C8:F8").Select
'without merging the cells we can align the data across the selection
Selection.HorizontalAlignment = xlCenterAcrossSelection
Range("C8:F8").Interior.ColorIndex = 5
End Sub