用户表单的无效属性值错误

时间:2019-09-10 06:13:09

标签: excel vba

我尝试遍历多个线程来找到我需要的答案,但还无法对其进行梳理。

我的用户表单中有某些组合框,并且有一个按钮可以上传详细信息。将详细信息上传到我的Excel工作表后,我希望表单清除所有内容并重置为空白。数据在excel文件中得到了完美的更新,但是每次我收到一条错误消息,指出“无效的属性值”。我希望能够上传详细信息而不会出现错误。我尝试将组合框样式设置为列表,但是,它仍然给我相同的错误

此外,如果用户在组合框中选择一个值并随后将其删除,则再次弹出相同的消息,直到用户从列表中选择一个值,该用户才能移动到另一个字段。我希望用户能够删除条目或仅从列表中选择条目(这就是为什么我需要将匹配项设置为True的原因。)

有人可以指导

PFB代码:

Private Sub CmdUploadDatabaseDetails_Click()

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Set wb = Workbooks.Open("C:\Users\anup.patil\Desktop\Dashboard 
    Testing.xlsx")
    wb.Activate
    IsEntryBlank = CheckIfBlanksDatabase

    If IsEntryBlank = True Then
        MsgBox "Please fill all the mandatory details"
        wb.Close False 
        cwb.Activate
        Me.CBMonth.SetFocus
        Exit Sub
    End If

    Sheets("Database").Select
    Range("B1").End(xlDown).Select
    Selection.Copy
    ActiveCell.Offset(1).Select
    ActiveSheet.Paste

    Application.CutCopyMode = False
    Lastrow = Sheets("Database").Cells(Rows.Count, "A").End(xlUp).Row
    Cells(Lastrow + 1, 1).Select

    ActiveCell.Value = Me.CBMonth.Value
    ActiveCell.Offset(, 2).Value = Me.TBParentCo.Text
    ActiveCell.Offset(, 3).Value = Me.TBSubsidaryCo.Text
    ActiveCell.Offset(, 4).Value = Me.CBCustomerCat.Text
    ActiveCell.Offset(, 5).Value = Me.TBContactName.Text
    ActiveCell.Offset(, 6).Value = Me.TBDesignation.Text
    ActiveCell.Offset(, 7).Value = Me.TBDept.Text
    ActiveCell.Offset(, 8).Value = Me.CBVertical.Text
    ActiveCell.Offset(, 9).Value = Me.CBSubVertical.Text
    ActiveCell.Offset(, 10).Value = Me.TBOperatingLoc.Text
    ActiveCell.Offset(, 11).Value = Me.TBNearbyHKVBr.Text
    ActiveCell.Offset(, 12).Value = Me.TBOperatingLocAddr.Text
    ActiveCell.Offset(, 13).Value = Me.CBOperatingLocState.Text
    ActiveCell.Offset(, 15).Value = Me.CBDecisionMakingUnit.Text
    ActiveCell.Offset(, 16).Value = Me.TBHOCentralized.Text
    ActiveCell.Offset(, 17).Value = Me.TBMobileNo.Text
    ActiveCell.Offset(, 18).Value = Me.TBPhoneNo.Text
    ActiveCell.Offset(, 19).Value = Me.TBEmail.Text
    ActiveCell.Offset(, 20).Value = Me.CBRelationshipBuild.Text
    ActiveCell.Offset(, 21).Value = Me.TBMemberOfAssoc.Text
    ActiveCell.Offset(, 22).Value = Me.TBListOfEmpanelled.Text
    ActiveCell.Offset(, 23).Value = Me.CBGiftAllowed.Text
    ActiveCell.Offset(, 24).Value = Me.CBGiftDeliveryMode.Text
    ActiveCell.Offset(, 25).Value = Me.TBSurvPotential.Text

    Me.CBMonth.ListIndex = -1
    Me.CBMonth.Value = ""
    Me.TBParentCo.Value = ""
    Me.TBSubsidaryCo.Value = ""
    Me.CBCustomerCat.Value = ""
    Me.TBContactName.Value = ""
    Me.TBDesignation.Value = ""
    Me.TBDept.Value = ""
    Me.CBVertical.Value = ""
    Me.CBSubVertical.Value = ""
    Me.TBOperatingLoc.Value = ""
    Me.TBNearbyHKVBr.Value = ""
    Me.TBOperatingLocAddr.Value = ""
    Me.CBOperatingLocState.Value = ""
    Me.CBDecisionMakingUnit.Value = ""
    Me.TBHOCentralized.Value = ""
    Me.TBMobileNo.Value = ""
    Me.TBPhoneNo.Value = ""
    Me.TBEmail.Value = ""
    Me.CBRelationshipBuild.Value = ""
    Me.TBMemberOfAssoc.Value = ""
    Me.TBListOfEmpanelled.Value = ""
    Me.CBGiftAllowed.Value = ""
    Me.CBGiftDeliveryMode.Value = ""
    Me.TBSurvPotential.Value = ""

    Me.CBMonth.SetFocus

    wb.Close True

    MsgBox "Details uploaded successfully"

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub

0 个答案:

没有答案