是否有表格控制按钮编辑标题的方法吗? [英] Is there a way to edit caption on Form Control buttons?

查看:119
本文介绍了是否有表格控制按钮编辑标题的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能(在一张纸上更改事件),改变表单控件按钮的标题文字?

Is it possible (on a sheet change event), to change the caption text of a Form Control button?

在理想情况下,我想一个变量加入到根据工作簿中的其他数据的现有按钮标题。

Ideally, I would like to add a variable into the existing button caption depending on other data in the workbook.

推荐答案

好了,右键单击在S preadsheet并选择View code

Well, right click the Sheet1 tab on the bottom of spreadsheet and select view code

复制粘贴以下code

Copy paste the following code

Private Sub Worksheet_Activate()
    Buttons("Button 1").Caption = "NEW TEXT"
End Sub

在Sheet1中被激活这个事件触发了,它改变了按钮上的标题为 NEW TEXT

This event fires up when Sheet1 gets activated and it changes the caption on the button to NEW TEXT

显然,你可以参考你的按钮按名称或它们的索引。你会修改按钮1如果你想修改一个不同的对象上的文字。

Obviously you can refer to your buttons either by name or their index. You would to modify the "Button 1" if you want to modify the text on a different object.

您可以为它指定一个前pression的变量或评估如果更换新文本

You can assign it a variable or evaluation of an expression if you replace the "NEW TEXT"

例如

如果对 Sheet2中您在A1单元格中键入任何你可以修改code后面工作表Sheet1,并使用

if on Sheet2 you type anything in the cell A1 you can modify the code behind Sheet1 and use

Private Sub Worksheet_Activate()
    Buttons("Button 1").Caption = Sheets("Sheet2").Range("A1")
End Sub

这样每次激活工作表Sheet1上的按钮文本将工作表Sheet1从被拾起,单元格A1

this way every time you activate Sheet1 the text on a button will be picked up from Sheet1, Cell A1

要找出按钮的名称看这里

To find out the name of the button look here

这篇关于是否有表格控制按钮编辑标题的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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