从字符串 (VBA) 中引用 Excel 用户窗体控件名称值 [英] Referencing Excel Userform Control Name Value From String (VBA)
问题描述
通常在 Excel VBA 中引用用户窗体控件值时,我会输入一些影响 radiobutton.value 的内容
Typically when referencing a userform control value in Excel VBA I would enter something to the effect of radiobutton.value
但是,我希望能够使用字符串作为用户控件的名称.这背后的想法是能够动态地生成控件名称并从中引用一个值.
However, I want to be able to use a string as the name of the user control. The idea behind this would be to dynamically be able to generate the control name and reference a value from it.
例如,我可能想引用 ctradiobutton.value 一次,然后引用 eradiobutton.value,这些控件已经存在于表单中,我只想引用与当前迭代中创建的字符串不同的控件名称.
For example I may want to reference ctradiobutton.value one time, and etradiobutton.value the next, these controls already exist on the form, I just want to reference a different name of the control from a string created on the current iteration.
推荐答案
像这样(Me
是 UserForm)
Like this (where Me
is the UserForm)
Me.Controls("TextBox1").Value
这篇关于从字符串 (VBA) 中引用 Excel 用户窗体控件名称值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!