Name | Examination |
Mary | Pass |
Peter | Fail |
Kate | Fail |
John | Pass |
Victoria | Pass |
Do you remember how were the tables with the final classification of our exams at school? Normally they were not a simple white table with the names and results, but a table with two contrasting colours to make it easier to be read by us.
It is very easy to paint a table with two different colours with VBA:
1. Paint manually the second row of the table with the colour you want.
2. Select the whole table.
3. Run the following macro.
Sub number_of_rows()
For a = 3 To Selection.Tables(1).Rows.count
If a Mod 2 = 0 Then
Selection.Tables(1).Rows(a).Shading.BackgroundPatternColor = Selection.Tables (1).Rows(2).Shading.BackgroundPatternColor
End If
Next a
End Sub
No comments:
Post a Comment