标签:div sel with http font 格式化 逻辑 pre cells
1 Sub 格式化工资条() 2 Dim i% 3 i = Cells(Rows.Count, 1).End(xlUp).Row 4 For j = 1 To i 5 If j Mod 2 Then 6 ‘If j Mod 2 =1 Then 与上一句等效,因为1相当于Ture这个逻辑值,0相当于False 7 ‘这一句是对奇数行进行操作 8 With Cells(j, 1).EntireRow.Range("a1:g1").Font 9 ‘EntireRow 选取到整行 10 .Bold = True 11 .Size = 8 12 .ColorIndex = 56 13 End With 14 Else ‘对偶数行进行操作 15 With Cells(j, 1).EntireRow.Range("a1:g1").Interior 16 ‘为什么偶数行(不是第一行)还是用A1:G1?因为相对区域引用(Range.Range) 17 .ColorIndex = 40 18 End With 19 End If 20 Next j 21 End Sub 22 23 Sub 清除格式化() 24 Selection.ClearFormats 25 End Sub
效果图:
标签:div sel with http font 格式化 逻辑 pre cells
原文地址:http://www.cnblogs.com/gilgamesh-hjb/p/7482101.html