求助excel大神,如何通过挑选关键字来自动选择对应的单元格内容
展开全部
'以下是通过输入关键字,来选中所有包含此关键字的单元格的宏代码,请参考
Public Sub 关键字群选()
Dim MyStr As String
MyStr = InputBox("请输入关键字:", "按关键字群选")
If MyStr = "" Then Exit Sub
Dim rng As Range, MyRngAddr As String
For Each rng In ActiveSheet.UsedRange
If InStr(1, rng.Value, MyStr, vbBinaryCompare) > 0 Then
MyRngAddr = IIf(MyRngAddr = "", rng.Address, MyRngAddr & "," & rng.Address)
End If
Next
If MyRngAddr <> "" Then ActiveSheet.Range(MyRngAddr).Select
End Sub
Public Sub 关键字群选()
Dim MyStr As String
MyStr = InputBox("请输入关键字:", "按关键字群选")
If MyStr = "" Then Exit Sub
Dim rng As Range, MyRngAddr As String
For Each rng In ActiveSheet.UsedRange
If InStr(1, rng.Value, MyStr, vbBinaryCompare) > 0 Then
MyRngAddr = IIf(MyRngAddr = "", rng.Address, MyRngAddr & "," & rng.Address)
End If
Next
If MyRngAddr <> "" Then ActiveSheet.Range(MyRngAddr).Select
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询