【发布时间】:2021-08-25 07:36:40
【问题描述】:
我需要将两列与数字进行比较。可能有多个重复项。我需要开始通过 B 在 C1 中查找第一个值,并突出显示与红色的第一个重合并将该单元格的地址放入 D1 现在我只突出显示第一个巧合代码
Sub Find_First()
Dim FindString As String
Dim myColor As Variant
Dim Rng As Range
myColor = Array("3")
On Error GoTo 0
FindString = Worksheets("2017").Range("C1").Value
With TargetRange
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Rng.Interior.ColorIndex <> 3 Then
If Not Rng Is Nothing Then
Rng.Interior.ColorIndex = myColor(I)
Else
MsgBox "Nothing found"
End If
Else
MsgBox "Colored"
End If
End With
End Sub
【问题讨论】:
标签: excel vba find compare highlight