我正在创建一个 VBA 应用程序,并且我有以下代码:
Dim previousCell As range
Private Sub Worksheet_SelectionChange(ByVal target As range)
Application.EnableEvents = False
On Error GoTo ws_exit:
Set previousCell = target
getEffort (previousCell) '**Here i get object required**
ws_exit:
Application.EnableEvents = True
MsgBox Err.Description
End Sub
Private Function getEffort(ByVal cell As range)
' do soemthing
End Sub
我不确定为什么会收到错误消息: Object required error at getEffort(previousCell)
. 如果我通过Target
,它的工作原理。
谢谢