excel - 如何强制 Active-X 组合框从溢出的数组中刷新其下拉列表
问题描述
我有一个工作簿,我正在尝试使用 Filter() 公式的结果填充 Active-X 组合框下拉列表,该公式在支持工作表中返回溢出的数组。
我已经命名了公式为“dynamiclist_1”的单元格,实际上我还有一些其他命名范围和其他一些名为“dynamiclist_2”、“dynamiclist_3”等的过滤器()公式,当然每个都有不同的值
现在,我的目标是,当用户双击 MainSheet 中的 Maintable 单元格时,组合框会根据单击的目标单元格找到要使用的正确动态列表,并用列表填充其下拉列表。
此外,如果该列表的内容发生变化(基于 Maintable 其他部分中的用户选择),组合框下拉列表会自行更新。
问题:
当我新打开工作簿并第一次双击时,组合框下拉列表仅填充一次。下拉列表正确填充了 dynamiclist_X 中的值。
但是,如果我在其他地方双击,当 dynamiclist_Y 应该应用时(或者就此而言,当 dynamiclist_X 应用但它的内容已经更新时),组合框下拉菜单仍然显示以前的值!我尝试了多种方法,但无论什么列表都不会刷新。
下面是我正在使用的代码:
Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Set cboTemp = ws.OLEObjects("InterDependCombo")
On Error Resume Next
With cboTemp
'clear and hide the combo box
.Object.List = ""
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
If Target.Validation.Type = 3 Then
'if the cell contains a data validation list
Cancel = True
' Application.EnableEvents = False
With cboTemp
'show the combobox with the list
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
If Not Intersect(Target, ActiveSheet.ListObjects("mainTable").ListColumns("Column1").DataBodyRange) Is Nothing Then
.Object.List = Sheets("dynamic Lists").Range("dynamicList_1#").Value
Else
.Object.List = Sheets("dynamic Lists").Range("dynamicList_2#").Value
End If
End With
cboTemp.Activate
End If
Application.EnableEvents = True
End Sub
我已经尝试过 .Object.list
, , and not的 .listfillrange
各种组合 #
,但是一旦列表被加载一次,结果就不会改变。代码似乎正确流动,即执行了正确的行。
请问有人可以帮我强制这个组合框刷新吗?
谢谢p
解决方案
推荐阅读
- java - 在 Java 中克隆二维数组
- c# - 无法在 WindowsForm 继承上调整 UI 组件的大小 (Visual Studio 2015)
- ruby-on-rails - 如何在 JS 框中显示带有 Active Storage 的图像变体?
- javascript - Lightbox/iframe 中的 Worldpay Javascript API 托管集成不起作用
- ios - 在 NSMutableAttributedString 的子类中调用 append 时应用程序崩溃
- reactjs - 更改所选选项卡的图标颜色 - react-native-router-flux
- devextreme-angular - 以自定义语言本地化 devextreme dx-date-box Angular 2+
- html - &#_integer_; 是什么意思?在 URL SRC 中做什么?
- java - CMD 上不显示 JAVA 版本
- mininet - 如何在 mininet 上添加控制器