要求:双击工作表,成绩底于60分的单元格底纹变成浅黄色;
代码:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim N As Integer
10 N = Range("A65536").End(xlUp).Row
Dim W As Range '声明单元格区域变量
20 Set W = Range("I2:I" & N)
30 W.ClearFormats '清除原有格式
40 For Each CJ In W '在集合对象中检查每一个成绩
50 If CJ < 60 Then
60 CJ.Interior.Color = RGB(255, 255, 0) '成绩所在的单元格底纹为浅黄色
70 End If
80 Next
End Sub