• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Excel-VBA:从表单控件获取值

用户头像
it1352
帮助1

问题说明

嵌入工作表 sheet1 我有一个名为 combobox_test 的表单控件组合框,它选择了值 x

Embedded in the worksheet sheet1 I have a Form Control combo box named combobox_test and it has selected value x

除此之外,我还嵌入了一个按钮,当我按下它时,我希望它获取 combobox_test 的值并将其放在 something.Rows(y).但我无法让它工作并且有点沮丧.也许你可以指出我正确的方向

in addition to that, i also have embbeded a button that when i press it i want it to take the value of combobox_test and place it in something.Rows(y). But i cant get it working and am getting a bit frustrated. Maybe you can point me in the right direction

Sub ButtonPressed_sample()
    Dim value As String

    Set putItRng = Range("theCells")        
    putItRng.Rows(1) = ActiveSheet.Shapes("combobox_test").Value        
End Sub

有什么建议吗?我是 VBA 的绝对初学者,所以请尽可能详细.谢谢

Any advise? Am an absolute beginner in VBA, so please be as detailed as you can. Thanks

正确答案

#1

我不确定这是你想要的,但这是一个开始.Shape 对象没有 Value 属性,这是错误的来源.有一个 DropDown 对象已被弃用,但仍然可用.

I'm not sure this is what you want, but it's a start. The Shape object doesn't have a Value property, which is the source of the error. There is a DropDown object that is deprecated, but still available.

Sub ButtonPressed_sample()

    Set putitrng = Range("theCells")
    putitrng.Rows(1) = ActiveSheet.DropDowns("combobox_test").value

End Sub

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgakak
系列文章
更多 icon
同类精品
更多 icon
继续加载