引用Excel Userform控件名字符串值(VBA) [英] Referencing Excel Userform Control Name Value From String (VBA)

查看:476
本文介绍了引用Excel Userform控件名字符串值(VBA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当在Excel VBA中引用userform控件值时,我将输入一些效果,例如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一次,和etradiobutton.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

这篇关于引用Excel Userform控件名字符串值(VBA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆