我正在寻找一个简单的宏来查找日期,并选择所有包含该日期的单元格(然后我将使用另一个工作宏来修改所选单元格)。但是我找不到并选择工作。
此刻,代码正在拾取第一个“ Jul-18”,然后吐出不匹配消息。
任何帮助将不胜感激;
Sub FIND()
On Error GoTo nomatch
Cells.FIND(What:=Jul - 18, LookIn:=xlValues).Select
nomatch:
MsgBox ("Not Found")
End Sub
答案 0 :(得分:1)
您应该能够轻松地使其适应您的需求。
[![在此处输入图片描述] [1]] [1]
Sub FindAndSelectAll()
Dim str As String, c As Range, r As Range
Dim strFind As String
Dim rSearch As Range
Set rSearch = ActiveSheet.Cells
strFind = InputBox("Please enter search string")
With rSearch
Set c = .Find(strFind, LookIn:=xlValues)
If Not c Is Nothing Then
Set r = c
str = c.Address
Do
Set r = Union(r, c)
ActiveSheet.Range(c.Address).Activate
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> str
End If
.Activate
If Not r Is Nothing Then r.Select
End With
End Sub