我有这段代码,它使用用户通过输入框输入的值来查找匹配项。我希望突出显示找到的数据,但我的代码没有这样做。
Dim holdstr As String
Dim fset As Range
holdstr = UCase(InputBox("Enter name"))
For i = 2 To Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
If holdstr = Sheet1.Cells(i, 1).Value Then
MsgBox "Record found!", vbInformation, "Message"
txtFirst.Text = Sheet1.Cells(i, 1).Value
txtLast.Text = Sheet1.Cells(i, 2).Value
txtMid.Text = Sheet1.Cells(i, 3).Value
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
Next i