Wednesday, 13 September 2017

VBA Range Objects Examples

RANGE OBJECT SOME EXAMPLES

  Rem Just in case there is anything on the
    Rem worksheet, delete everything
    Range("A:K").Delete
    Range("1:20").Delete
   
    Rem Create the sections and headings of the worksheet
    Range("B2") = "Georgetown Dry Cleaning Services"
    Range("B2").Font.Name = "Rockwell Condensed"
    Range("B2").Font.Size = 24
    Range("B2").Font.Bold = True
    Range("B2").Font.Color = vbBlue
   
    Range("B5") = "Order Identification"
    Range("B5").Font.Name = "Cambria"
    Range("B5").Font.Size = 14
    Range("B5").Font.Bold = True
    Range("B5").Font.ThemeColor = 5
   
    Rem To draw a thick line, change the bottom
    Rem borders of the cells from B5 to J5
    Range("B5:J5").Borders(xlEdgeBottom).LineStyle = xlContinuous
    Range("B5:J5").Borders(xlEdgeBottom).Weight = xlMedium
   
    Range("B6") = "Receipt #:"
    Range("D6:F6").Borders(xlEdgeBottom).LineStyle = xlContinuous
    Range("D6:F6").Borders(xlEdgeBottom).Weight = xlHairline
   
    Range("G6") = "Order Status:"
    Range("I6:J6").Borders(xlEdgeBottom).LineStyle = xlContinuous
    Range("I6:J6").Borders(xlEdgeBottom).Weight = xlHairline
   
    Range("B7") = "Customer Name:"
    Range("D7:F7").Borders(xlEdgeBottom).LineStyle = xlContinuous
    Range("D7:F7").Borders(xlEdgeBottom).Weight = xlHairline
   
    Range("G7") = "Customer Phone:"
    Range("I7:J7").Borders(xlEdgeBottom).LineStyle = xlContinuous
    Range("I7:J7").Borders(xlEdgeBottom).Weight = xlHairline
   
    Rem To draw a thick line, change the bottom
    Rem borders of the cells from B5 to J5
    Range("B8:J8").Borders(xlEdgeBottom).LineStyle = xlContinuous
    Range("B8:J8").Borders(xlEdgeBottom).Weight = xlThin
   
    Range("B9") = "Date Left:"

    Range("D9:F9").Borders(xlEdgeBottom).LineStyle = xlContinuous

No comments:

Post a Comment

JOTHIDAM KARPOM VANGA