英文:
Unable to specify .RowSource for Combo Box
问题
我正在尝试在Excel中使用VBA创建一个依赖的组合框。以下是我的代码:
Option Explicit
Private Sub conduitTypeBox_Change()
Select Case conduitTypeBox.Value
Case Is = "IMC"
conduitSizeBox.RowSource = "imcSize"
Case Is = "LFMC"
conduitSizeBox.RowSource = "lfmcSize"
Case Is = "RMC"
conduitSizeBox.RowSource = "rmcSize"
Case Is = "PVC (Schedule 80)"
conduitSizeBox.RowSource = "pvc80Size"
Case Is = "PVC (Schedule 40)"
conduitSizeBox.RowSource = "pvc40Size"
Case Is = "PVC (Type A)"
conduitSizeBox.RowSource = "pvcaSize"
Case Is = "PVC (Type EB)"
conduitSizeBox.RowSource = "pvcebSize"
End Select
End Sub
概念是用户在第一个组合框中选择一种导管类型(例如“IMC”),然后第二个组合框将填充与导管类型唯一的尺寸。我使用名称管理器为数据范围创建了一个名称(并确保它具有整个工作簿的范围),但是我收到运行时错误'438':对象不支持此属性或方法。我理解问题是什么,但我不完全确定为什么会有问题。当我键入“conduitSizeBox.
”时,RowSource
不会出现在可用属性列表中。有人知道为什么吗?
我尝试查找其他属性,但没有找到适合我的需求的内容。
英文:
I am trying to make a dependent combo box in Excel using VBA. Here is my code:
Option Explicit
Private Sub conduitTypeBox_Change()
Select Case conduitTypeBox.Value
Case Is = "IMC"
conduitSizeBox.RowSource = "imcSize"
Case Is = "LFMC"
conduitSizeBox.RowSource = "lfmcSize"
Case Is = "RMC"
conduitSizeBox.RowSource = "rmcSize"
Case Is = "PVC (Schedule 80)"
conduitSizeBox.RowSource = "pvc80Size"
Case Is = "PVC (Schedule 40)"
conduitSizeBox.RowSource = "pvc40Size"
Case Is = "PVC (Type A)"
conduitSizeBox.RowSource = "pvcaSize"
Case Is = "PVC (Type EB)"
conduitSizeBox.RowSource = "pvcebSize"
End Select
End Sub
The concept is that the user selects a type of conduit (ex. "IMC") in the first combo box and then a second combo box populates with sizes unique to the conduit type. I created a name for the range of the data using the Name Manager (and ensured it has the scope of the entire workbook), however I am getting run-time error '438': Object doesn't support this property or method. I understand what the issue is, but I'm not entirely sure why it's an issue. When I type "conduitSizeBox.
", RowSource
does not appear in the list of available properties. Would anyone have any idea why?
I tried looking for other properties and didn't find anything that fit my needs.
答案1
得分: 0
使用Listfillrange
属性代替Rowsource
。
英文:
Use the Listfillrange
property instead of Rowsource
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论