|
Sub FilterData()
Dim ws As Worksheet
Dim rng As Range
Dim lastRow As Long
Dim keyword As String
' 设置工作表
Set ws = ThisWorkbook.Sheets("核实") ' 替换为你的工作表名
' 获取A列的最后一行
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' 设置筛选范围
Set rng = ws.Range("A2:A" & lastRow)
' 输入关键词
keyword = InputBox("请输入你要筛选的关键词:", "关键词筛选")
' 应用自动筛选
rng.AutoFilter Field:=1, Criteria1:="*" & keyword & "*", Operator:=xlAnd
End Sub
|
|