Excel Vba以编程方式选择vba userform元素? [英] Excel Vba Programaticly select vba userform element?

查看:203
本文介绍了Excel Vba以编程方式选择vba userform元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

我正试图找到一种方法来获得一个类似于这个psudocode的东西

i am trying to find a way to get a peice of vba to do something similar to this psudocode

函数  something(name)

Function something(name)

在Userform1中找到一个名为name的元素并返回其标题

find inside Userform1 an element called name and return its caption

结束函数

我尝试了Userform1.name.Caption,但是它找到了一个名为'name'而不是给出的名字

I tried Userform1.name.Caption but it looks for something called 'name' instead of the name given

任何想法?

很多appriciated。

Much appriciated.

推荐答案

尝试

Function GetCaption(ControlName As String) As String
    On Error GoTo ErrHandler
    GetCaption = UserForm1.Controls(ControlName).Caption
    Exit Function
ErrHandler:
    GetCaption = "- not valid -"
Exit Sub





这篇关于Excel Vba以编程方式选择vba userform元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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