获取424运行时错误,需要对象

时间:2015-08-07 08:37:07

标签: vba

请帮助解决下面的代码错误424

Public counter As String

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
    If ActiveSheet1.Name = Sheet2.Name Then
        If counter = 0 Or counter = Null Then
            Call LLP_Hide
        End If
    End If
End Sub

1 个答案:

答案 0 :(得分:0)

ActiveSheet1删除1。

如果要计算counter,则应将其声明为Integer类型,而不是String

无论如何,这部分代码也会导致错误:counter = 0。将其替换为counter = "0"或更改counter的类型。

Public counter As Integer

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
    If ActiveSheet.Name = Sheet2.Name Then
        If counter = 0 Then
            Call LLP_Hide
        End If
    End If
End Sub