Sample Macros > Format Table Style

Format Table Style

Tags:  

This macro is used to format a cell range as a Table with headers, borders and alternating row colors. A demo of this macro can be seen on this spreadsheet in Zoho.
Sub FormatTable()
count = 0
For each x in Selection.rows
If count = 0 Then
x.Interior.Color=RGB(255,137,0)
x.Font.Color = RGB(255,255,255)
With x.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With x.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlMedium
End With
Else
If count mod 2 = 0 Then
x.Interior.Color=RGB(255,255,200)
End If
With x.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Color = RGB(255,137,0)
.Weight = xlThin
End With
End If
count = count + 1
Next x
With x.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = black
End With
End Sub


 RSS of this page