在对 ID 进行简单搜索时出现运行时错误 91...为什么?(已解决:搜索失败,因为单元格被格式化为带逗号的数字 - 很奇怪但却是事实,将格式更改为“常规”后,它就可以完美运行了!谢谢大家!)
Public Sub SearchID()
Dim foundCell As Range
Dim searchEmpID As String
Dim searchRange As Range
Dim rowFound As Integer
searchEmpID = "EmpID_0112"
Set searchRange = Sheets("HoursData").Range("DY2:DY999")
Sheets("HoursData").Select
Set foundCell = searchRange.Find(What:=searchEmpID, LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
MsgBox Sheets("HoursData").Range("DY115").Value '<<<<< 数据/ID 在那里,请参见截图。
rowFound = foundCell.Row '<<<<<<<<<<<< Why this produces Runtime Error 91/Object Variable Not Set...???
End Sub