所以,我有一个工作表,我想在其中搜索 Range("A:A") 中的 Range("M" & i) 的值。但是,当我尝试运行此代码时,它返回错误:“运行时错误'91':对象变量或未设置块。当我单击调试时,它发现错误
SearchIn = Range("A:A")
我确实谷歌了互联网和这个网站(找到了一些东西),但我仍然无法解决这个问题。有人有线索吗?
Sub Find_Replace()
Dim i As Integer
Dim SearchIn As Range
Dim SearchedObject As Range
Dim FinalCell As Range
Dim SumCell As Range
i = 5
SearchIn = Range("A1:A740")
StartSearch = Range("A" & i)
FinalCell = Range("N" & i)
Do While i <= 740
SearchedObject = SearchIn.Find(What:="M" & i, After:=StartSearch, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If SearchedObject.Value = Range("M" & i).Value Then FinalCell = FinalCell.Value + SearchedObject.Offset(0, 5).Value
Loop
End Sub