Sub 查找()
Dim jieguo As String, p As String, q As String
Dim c As Range
jieguo = Application.InputBox(prompt:="请输入要查找的值:", Title:="查找", Type:=2)
If jieguo = "False" Or jieguo = "" Then Exit Sub
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With ActiveSheet.Cells
Set c = .Find(jieguo, , , xlWhole, xlByColumns, xlNext, False)
If Not c Is Nothing Then
p = c.Address
Do
c.Interior.ColorIndex = 4
q = q & c.Address & vbCrLf
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> p
End If
End With
MsgBox "查找数据在以下单元格中:" & vbCrLf & vbCrLf _
& q, vbInformation + vbOKOnly, "查找结果"
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub