求助:excel的函数

来源:百度知道 编辑:UC知道 时间:2024/05/22 05:27:12
各位高手,请帮忙编一个公式
在excel中如果在单元格A1中输入字母A,单元格C1就变成红色,而在单元格A1中输入字母B,单元格D1就变成红色,而在单元格A1中输入字母C,单元格E1就变成红色,请那位高手帮帮我,谢谢了

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandle

With Target
Select Case .Cells(1, 1).Value
Case "A"
.Cells(1, 3).Interior.ColorIndex = 3
.Cells(1, 3).Interior.Pattern = xlSolid
.Cells(1, 4).Interior.ColorIndex = xlNone
.Cells(1, 5).Interior.ColorIndex = xlNone
Exit Sub
Case "B"
.Cells(1, 4).Interior.ColorIndex = 3
.Cells(1, 4).Interior.Pattern = xlSolid
.Cells(1, 3).Interior.ColorIndex = xlNone
.Cells(1, 5).Interior.ColorIndex = xlNone
Exit Sub
Case "C"
.Cells(1, 5).Interior.ColorIndex = 3
.Cells(1, 5).Interior.Pattern = xlSolid
.Cells(1, 3).Interior.ColorIndex = xlNone