excelVB模糊查找各位,我想用EXCELVB的函数功能编写个
各位,我想用EXCEL 的函数功能编写个宏,用于查找某列中数据是否包含某一指定字段,请问可以用哪个函数,如何用? 别告诉我用EXCEL的模糊查询功能,我只想用函数,因为我要重复很多个特定字段,谢谢!
问题还没解决呀,那上传一段供参考吧。 Sub cxsj() Dim 查找值 As String, str1 As String, str2 As String Dim c As Range 查找值 = Application.InputBox(prompt:="请输入要查找的值:", Title:="查找", Type:=2) If 查找值 = "False" Or 查找值 = "" Then Exit Sub Application.ScreenUpdating = False Application.DisplayAlerts = False With ActiveSheet.Cells Set c = .Find(查找值, , , xlPart, xlByColumns, xlNext, False) If Not c Is Nothing Then str1 = c.Address Do c.Interior.ColorIndex = 4 '加亮显示 str2 = str2 & c.Address & vbCrLf Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> str1 End If End With MsgBox "查找到指定数据在以下单元格中:" & vbCrLf & vbCrLf & str2, vbInformation + vbOKOnly, "查找结果" Application.ScreenUpdating = True Application.DisplayAlerts = True End Sub