Excel VBA选择更改 [英] Excel VBA selection change
问题描述
Hy那里
我是VBA编码的新手。我搜索了很多我的问题的答案,但找不到任何帮助我的东西;也许在这里我是对的。
我想将Worksheet_SelectionChange用于特定的工作表。这个特定的工作表我想在代码中定义
例子(这个例子毫无意义,我知道,但这是展示我问题的最佳方式):
我的工作簿中有三个工作表:ws1,ws2,ws3。 ws1和ws3都是空的,ws2有一些值。
当我打开工作簿时,我搜索哪个工作表不是空的。这个工作到目前为止。
现在我发现工作表不是空的,我想为这个工作表设置Worksheet_SelectionChange。
如何我这样做了吗?
谢谢大家
Hy there
I'm a newby in coding with VBA. I searched alot for an answer for my problem, but couldn't find anything that helped me; maybe here I'm right.
I want to use the Worksheet_SelectionChange for a specific worksheet. This specific worksheet I want to define in the code
example (this example makes no sense, I know, but it is the best way to show my problem):
I have three worksheets in my workbook: ws1, ws2, ws3. ws1 and ws3 are empty, ws2 has some values.
When I open the workbook, I search wich worksheet is not empty. This works so far.
Now that I found wich worksheet is not empty, I want to set the Worksheet_SelectionChange for this worksheet.
How do I do this?
Thanks Guys
推荐答案
这里 [ ^ ]是您需要了解的所有内容;)请阅读新类模块中的应用程序事件部分并根据需要修改代码。
Here[^] is a everything what you need to know ;) Please, read Application Events In A New Class Module section and modify code to your needs.
我找到了解决方案。
我需要将我的代码放在THISWORKBOOK中这样的子目录
I found the solution.
I need to put my code in THISWORKBOOK in a sub like this
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
这篇关于Excel VBA选择更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!