看过有关的文章,代码如下:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rg As Range
For Each rg In Range("A1 Z1")
Select Case rg.Value
Case "公司名1"
rg.Interior.ColorIndex = 3
Case "公司名2"
rg.Interior.ColorIndex = 6
Case "公司名3"
rg.Interior.ColorIndex = 4
Case "公司名4"
rg.Interior.ColorIndex = 5
End Select
Next
End Sub
可是,点击后出错。提示方法RANG作用时失败,问题出在哪里呢?作者: pureshadow 时间: 2007-12-10 16:38
我这儿有一个,抄的
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Select Case Target.Value
Case "蓝"
Target.Font.Color = RGB(255, 255, 255)
Target.Interior.Color = RGB(0, 0, 255)
Case "红"
Target.Font.Color = RGB(255, 255, 255)
Target.Interior.Color = RGB(255, 0, 0)
Case "黄"
Target.Font.Color = RGB(0, 0, 0)
Target.Interior.Color = RGB(255, 255, 0)