Border Line Styles - Property

     

  • This property denotes about the line styles
  •  

    Code:

    Private Sub CommandButton1_Click()
    Denotes about various kinds of Line styles Range("A3").Borders.LineStyle = xlcontinues
    Range("A3").Borders.Weight = xlThick
    Range("A5").Borders.LineStyle = xlDouble
    Range("A7").Borders.LineStyle = xlDashDotDot
    End Sub

     

     

    BorderAround Method

     

     

    Line Styles:

    Code:

    Private Sub CommandButton1_Click()
    Range("A1:A11").Value = "Sriguranjani"
    To expand the cell according the value in cell
    Columns(1).AutoFit
    To Create Border
    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

     

  • FormatNumber
  • FormatCurrency - Number preceded by currency symbol
  • FormatPercentage - Number followed by currency
  •  

    Number Formatting

     

  • Denotes about the DECIMALS..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

  • xledgetop
  • xlEdgeLeft
  • xlEdgeBottom
  • xlEdgeRight
  • xlDiagonalDown
  • xlDiagonalUp
  • xlInsideHorizontal
  • State about Horizontal alignment Properties

     

  • We can adjust the text in CENTER,LEFT,RIGHT
  •  

    Copy code:

    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

     

    Copy code:

    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

     

    Copy code:

    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