我有一個功能,應經常運行:方法細胞對象-Worksheet失敗
Public Function FindNumberofhandle(stsmenthandle As String) As Long
Dim r As Long
Dim LastUsedRow As Long
LastUsedRow = Worksheets(2).Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
For i = 1 To LastUsedRow
If ActiveWorkbook.Sheets(2).Cells(i, 2).Value = stsmenthandle Then 'ERROR HERE
r = i
End If
Next i
FindNumberofhandle = r
End Function
我收到此錯誤:
run time error -2147417748(80010108)
Method Cells of Object Worksheet failed
我應該怎麼做才能解決這個問題?
什麼線你得到的錯誤? – 99moorem
我在上面的代碼中註釋它 – Kaja
也許'ActiveWorkbook.Sheets(2)'不是工作表,而是圖表? –