|
代码如下:
- Sub 查找()
- Dim arr, i As Long, mStr As String, m As Long, mRow As Long
- arr = Sheet1.UsedRange.Value
- mStr = arr(2, 2)
- For i = 8 To UBound(arr)
- If InStr(arr(i, 2), mStr) Then m = m + 1
- Next
- If m = 0 Then
- MsgBox "找不到关键词所在单元格!", 16 + 0, "提醒": End
- ElseIf m = 1 Then
- If Sheet1.AutoFilterMode = True Then Sheet1.AutoFilterMode = False
- mRow = Sheet1.Range("B8:B" & UBound(arr)).Find(mStr).Row
- Sheet1.Rows(mRow).Interior.ColorIndex = 6
- Sheet1.Range("B" & mRow).Select
- ElseIf m > 1 Then
- Sheet1.Range("A7:G7").AutoFilter Field:=1
- ActiveSheet.Range("A7:G" & UBound(arr)).AutoFilter Field:=2, Criteria1:="=*" & mStr & "*"
- Else
- End
- End If
- End Sub
- Sub 解除筛选()
- If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|