vba 如何在工作表中创建链接文本框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1211023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:39:11  来源:igfitidea点击:

How to create Linked textbox in worksheet?

excelvba

提问by mik

I want to have a textbox or a caption in an excel worksheet, that displays the value of some cell from this worksheet. Is it possible?

我想在 excel 工作表中有一个文本框或标题,以显示该工作表中某些单元格的值。是否可以?

回答by Gary McGill

You canuse a textbox control as Lance suggests, but there are other, perhaps better ways:

可以按照 Lance 的建议使用文本框控件,但还有其他可能更好的方法:

If you create an autoshape textbox (Insert->Picture->AutoShapes) you can link it to a singlecell by selecting it, then type (for example) "=A1" into the formula bar. You can then format and position it as you like.

如果您创建一个自动形状文本框(插入->图片->自动形状),您可以通过选择它来将其链接到单个单元格,然后在编辑栏中键入(例如)“=A1”。然后,您可以根据需要对其进行格式化和定位。

That's pretty cool, but not as cool as this: if you copy a rangeof cells, and then hold down the shift key as you choose the Edit menu, you'll see an option "Paste picture link". If you do this, it pastes a picture of the cells which gets updated when the cell values change. As Michael Caine never said, "not a lot of people know that".

这很酷,但没有这么酷:如果您复制一系列单元格,然后在选择“编辑”菜单时按住 shift 键,您将看到一个选项“粘贴图片链接”。如果您这样做,它会粘贴单元格的图片,当单元格值更改时,该图片会更新。正如迈克尔凯恩从未说过的那样,“没有多少人知道这一点”。

Note: I'm talking here about Excel 2003. I assume it still works in 2007, though the location of the various commands, etc. will have changed.

注意:我在这里谈论的是 Excel 2003。我认为它在 2007 年仍然有效,尽管各种命令的位置等会发生变化。

回答by Lance Roberts

Yes, but you don't need vba, you can just put the control on the sheet, and link it to the cell (when in control design mode, just right-click on it and go to properties).

是的,但是您不需要 vba,您可以将控件放在工作表上,并将其链接到单元格(在控件设计模式下,只需右键单击它并转到属性)。

回答by user3285344

In Excel 2013:

在 Excel 2013 中:

  1. Copy the desired range
  2. Do NOT create a text box
  3. Go to an area near where you want the "picture" of the referenced cells
  4. With "Ctrl" key pressed right click - paste special - other paste options - linked picture
  1. 复制所需范围
  2. 不要创建文本框
  3. 转到您想要引用单元格的“图片”附近的区域
  4. 按住“Ctrl”键右键单击 - 特殊粘贴 - 其他粘贴选项 - 链接图片

回答by Chris

Confirmed that it does work in Excel 2007 (you don't need to hold down shift).

确认它在 Excel 2007 中确实有效(您不需要按住 shift)。

Home tab->Paste (select down arrow)->As Picture->Paste Picture link

首页选项卡->粘贴(选择向下箭头)->作为图片->粘贴图片链接