Excel-VBA:从表单控件中获取值 [英] Excel-VBA: Getting the values from Form Controls
问题描述
嵌入工作表 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
推荐答案
我不确定这是你想要的,但这是一个开始.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
这篇关于Excel-VBA:从表单控件中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!