请教一个EXCEL方面的问题
向您请教一个问题:实际工作中化验结果查找数据手工查找易失误,下面是Excel2003工作表一部分:ABCDEFGHIJKLMNOPQR121538233617343938...
向您请教一个问题:实际工作中化验结果查找数据手工查找易失误,下面是Excel2003工作表一部分:
A B C D E F G H I J K L M N O P Q R
1 21 5 38
2 3 36 17
3
4 39 38 3 0 -17 21 -26 4 4 -3 0 19 8.8 13 36 53 10 15
5 1 3 7 8 10 10 13 13 15 18 21 27 27 27 28 36 36 37
6 7 1 3 0 -15 7 6 7 4 -3 0 8 3.5 5.3 4 21 10 15
7 2 3 7 8 10 10 13 13 15 18 21 27 27 27 28 36 36 37
8 7 11 3 0 -17 19 6 12 4 -3 0 8 3.5 5.3 4 21 10 15
问题1:怎样用公式法或VBA等方法在A4:R4行数据中查找并突出显示A1:C1单元格的数据(如单元格变色或者是字体颜色改变等),实现A1:C1数据改变后在A4:R4自动查找并突出显示?
问题2:怎样用公式法或VBA等方法在A4:R13行数据中查找并突出显示A1:C2单元格的数据(如单元格变色或者是字体颜色改变等),实现A1:C2数据改变后在A4:R13自动查找并突出显示?
谢谢! 展开
A B C D E F G H I J K L M N O P Q R
1 21 5 38
2 3 36 17
3
4 39 38 3 0 -17 21 -26 4 4 -3 0 19 8.8 13 36 53 10 15
5 1 3 7 8 10 10 13 13 15 18 21 27 27 27 28 36 36 37
6 7 1 3 0 -15 7 6 7 4 -3 0 8 3.5 5.3 4 21 10 15
7 2 3 7 8 10 10 13 13 15 18 21 27 27 27 28 36 36 37
8 7 11 3 0 -17 19 6 12 4 -3 0 8 3.5 5.3 4 21 10 15
问题1:怎样用公式法或VBA等方法在A4:R4行数据中查找并突出显示A1:C1单元格的数据(如单元格变色或者是字体颜色改变等),实现A1:C1数据改变后在A4:R4自动查找并突出显示?
问题2:怎样用公式法或VBA等方法在A4:R13行数据中查找并突出显示A1:C2单元格的数据(如单元格变色或者是字体颜色改变等),实现A1:C2数据改变后在A4:R13自动查找并突出显示?
谢谢! 展开
3个回答
展开全部
问题1:只要将以下代码放在数据源所在工作表中就可以实现A1:C1更改后自动更新查找目标并更换颜色。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row <> 1 Then Exit Sub
If Target.Column = 1 Then GoTo st
If Target.Column = 2 Then GoTo st
If Target.Column = 3 Then GoTo st
Exit Sub
st:
Cells.Select
Selection.Interior.ColorIndex = xlNone
Dim C
For C = 1 To 18
If Cells(4, C).Value = Range("A1").Value Then
Cells(4, C).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
End If
If Cells(4, C).Value = Range("B1").Value Then
Cells(4, C).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
End If
If Cells(4, C).Value = Range("C1").Value Then
Cells(4, C).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
End If
Next
End Sub
问题2.只要将以下代码放在数据源所在工作表中就可以实现A1:C2更改后自动更新查找目标并更换颜色。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row <> 1 Then
If Target.Row <> 2 Then Exit Sub
If Target.Column = 1 Then GoTo st
If Target.Column = 2 Then GoTo st
If Target.Column = 3 Then GoTo st
Exit Sub
End If
st:
Cells.Select
Selection.Interior.ColorIndex = xlNone
Dim C, R
For C = 1 To 18
For R = 4 To 13
If Cells(R, C).Value = Range("A1").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("B1").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("C1").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("A2").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("B2").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("C2").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
Next
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row <> 1 Then Exit Sub
If Target.Column = 1 Then GoTo st
If Target.Column = 2 Then GoTo st
If Target.Column = 3 Then GoTo st
Exit Sub
st:
Cells.Select
Selection.Interior.ColorIndex = xlNone
Dim C
For C = 1 To 18
If Cells(4, C).Value = Range("A1").Value Then
Cells(4, C).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
End If
If Cells(4, C).Value = Range("B1").Value Then
Cells(4, C).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
End If
If Cells(4, C).Value = Range("C1").Value Then
Cells(4, C).Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
End If
Next
End Sub
问题2.只要将以下代码放在数据源所在工作表中就可以实现A1:C2更改后自动更新查找目标并更换颜色。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row <> 1 Then
If Target.Row <> 2 Then Exit Sub
If Target.Column = 1 Then GoTo st
If Target.Column = 2 Then GoTo st
If Target.Column = 3 Then GoTo st
Exit Sub
End If
st:
Cells.Select
Selection.Interior.ColorIndex = xlNone
Dim C, R
For C = 1 To 18
For R = 4 To 13
If Cells(R, C).Value = Range("A1").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("B1").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("C1").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("A2").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("B2").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
If Cells(R, C).Value = Range("C2").Value Then
Cells(R, C).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
End If
Next
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在单元格格式里有这个功能,具体写法我忘了。就是那种可以自定义格式。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询