gpt4 book ai didi

vba - 需要错误 424 对象 - 似乎找不到错误

转载 作者:行者123 更新时间:2023-12-04 20:40:45 24 4
gpt4 key购买 nike

我对 VBa 很陌生,我正在尝试通过构建或复制现有的 vba 表来学习。
在这一个中,我在以下代码中遇到错误:

Private Sub lstLookup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'declare the variables
Dim cPayroll As String
Dim I As Integer
Dim findvalue
'error block
On Error GoTo errHandler:
'get the select value from the listbox
For I = 0 To lstLookup.ListCount - 1
If lstLookup.Selected(I) = True Then
cPayroll = lstLookup.List(I, 1)
End If
Next I
'find the payroll number
Set findvalue = Sheet2.Range("F:F").Find(What:=cPayroll, LookIn:=xlValues).Offset(0, -3)
'add the database values to the userform
cNum = 21
For X = 1 To cNum
Me.Controls("Reg" & X).Value = findvalue
Set findvalue = findvalue.Offset(0, 1)
Next
'disable adding
Me.cmdAdd.Enabled = False
Me.cmdEdit.Enabled = True
'error block
On Error GoTo 0
Exit Sub
errHandler::
MsgBox "An Error has Occurred " & vbCrLf & "The error number is: " _
& Err.Number & vbCrLf & Err.Description & vbCrLf & _
"Please notify the administrator"
End Sub

它给了我错误:“需要 424 对象”

我似乎找不到错误

有人能帮我吗?

提前致谢。

最佳答案

改变

Me.cmdAdd.Enabled = False
Me.cmdEdit.Enabled = True


Me.Controls("cmdAdd").Enabled = False
Me.Controls("cmdEdit").Enabled = True

关于vba - 需要错误 424 对象 - 似乎找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34179966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com