简体   繁体   English

为什么我无法使用excel VBA更新Listbox的RowSource属性?

[英]Why am I unable to update Listbox's RowSource property using excel VBA?

What my userform looks like with the properties window: 在属性窗口中,我的用户表单如下所示: 用户表格

This is my code: 这是我的代码:

With Worksheets("List of Accounts").ListObjects("ListofAccounts").ListColumns(1).Range
    Total_rows_Accounts = .Find(What:="*", _
    After:=.Cells(1), _
    Lookat:=xlPart, _
    LookIn:=xlFormulas, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious, _
    MatchCase:=False).Row
End With

If Total_rows_Accounts > 1 Then
    lbxCurrent.RowSource = "List of Accounts!A2:A4"
End If

What my worksheet looks like: 我的工作表如下所示:

帐户清单

The error: 错误:

错误

Your Range is incorrect. 您的范围不正确。 It should be lbxCurrent.RowSource = "'List of Accounts'!A2:A4" You're getting the error due to spaces in your sheet name 应该是lbxCurrent.RowSource = "'List of Accounts'!A2:A4"由于工作表名称中的空格,您会收到错误消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM