gpt4 book ai didi

VBA (Visual Basic) : ComboBox (Form Control) - Object doesn't support this property or method

转载 作者:行者123 更新时间:2023-12-03 09:07:24 25 4
gpt4 key购买 nike

刚注册! (尽管我已经使用该网站几年了哈哈!)。

我在 VBA 上遇到了一个问题,这让我发疯。希望有人可以解决我的问题。

我正在尝试引用我在 Sheet6 中手动添加的 ComboBox(Form Control)。它包含几个项目列表。然后我将遍历组合框中的每个项目并用它做一些事情..

但是对于我的生活,我无法理解我做错了什么?!

我不断收到运行时错误“438”:

Object doesn't support this property or method

This is the line the Run-time error occurs on:

Public Sub ReferralSummaries()

'Stop screen updates.
Application.ScreenUpdating = False

'Method Variables
Dim Lstrw As Long
Dim CurrentWb As Workbook
Dim ReferralSheet As Worksheet
Dim ResultsSheet As Worksheet
Dim ReferralSheetCBox As Object

'Initialize Variables
Set CurrentWb = ThisWorkbook
Set ReferralSheet = CurrentWb.Sheets("Referral Breakdowns")
Set ResultsSheet = CurrentWb.Sheets("Results")
Set ReferralSheetCBox = Worksheets(6)

'Check Date column and update accordingly
Call Update_Date_Column(ReferralSheet, ResultsSheet)

For i = 0 To ReferralSheetCBox.ComboBox1.Items.Count - 1 **(ERROR TRIGGERED HERE).**

任何帮助表示赞赏,请!

亲切的问候,
忍者

最佳答案

我认为你应该使用

Set ReferralSheetCBox = Worksheets(6).Shapes("ComboBox1")

然后你可以通过它的 ControlFormat访问它的属性。属性,例如:
Dim nItems As Long
nItems = ReferralSheetCBox.ControlFormat.ListCount

因此您显示的代码最后一行将是
For i = 0 To ReferralSheetCBox.ControlFormat.ListCount - 1

关于VBA (Visual Basic) : ComboBox (Form Control) - Object doesn't support this property or method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49078494/

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