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屋!