热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

将宏关联到工作表中的表单-AssociatemacrotoformsinanSheet

Couldanyonegivemeatiponthisproblem?谁能给我一个关于这个问题的小费?IhaveaddedthesetwoRoundedRectan

Could anyone give me a tip on this problem?

谁能给我一个关于这个问题的小费?

I have added these two "Rounded Rectangle" (B1 and B2) in my worksheet.

我在工作表中添加了这两个“圆角矩形”(B1和B2)。

Rectangles in the WorkSheet

I also have written the macro (mainMacro) below:

我也写了下面的宏(mainMacro):

Sub mainMacro() 

if "B1 was selected" then
  'do something
elseif "B2 was selected" then
   'do other thing.
end If 

End Sub

My question is: Is there any way to write a VBA code who will do something based on what retangle a user has clicked (as I wrote in the 'If' statement of the mainMacro)?

我的问题是:有没有办法编写VBA代码,根据用户点击的内容进行修改(正如我在mainMacro的'If'语句中所写的那样)?

Obs:I have noted that VBA identifies these rectangles as :Array("Rounded Rectangle x")

Obs:我注意到VBA将这些矩形标识为:Array(“Rounded Rectangle x”)

1 个解决方案

#1


0  

The easiest way I can think of doing what you want to do is to have a form control button instead of a shape.

我能想到做你想做的最简单的方法是使用表单控件按钮而不是形状。

If you open the developer tab, click insert and under form controls, put a button. In the button macro, you can add the code you want, so if that button is pressed, it will execute that macro.

如果打开开发人员选项卡,请单击插入并在表单控件下,放置一个按钮。在按钮宏中,您可以添加所需的代码,因此如果按下该按钮,它将执行该宏。

Then you can add the second code (currently under elseif in your code) to the second form control button.

然后,您可以将第二个代码(当前在代码中的elseif下)添加到第二个表单控件按钮。


推荐阅读
author-avatar
革启兵
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有