如何限制 Ctrl +以 Excel 工作表结束
我在第 500 - 503 行插入了一些数据。我故意将数据放置在这些行中,因为这些行将在宏中使用,而不是在用户视图中使用。与用户相关的数据在第100行结束。
我隐藏了第500 - 503行,但按Ctrl + End后,光标移动到第499行。
我的要求是按Ctrl + End后,光标应该在最后第 100 行的单元格。
那么,我该怎么做?
编辑:感谢您的所有回答。许多人建议我再准备一张非用户相关数据的表,但我没有。另外我不应该有 vba 脚本。(应该之前给你这些条件......我的错!)
I have some data inserted at Rows 500 - 503. I placed the data intentionally at those rows because these rows will be used in Macro's and not for User's view. The data concerned to the user ends at Row 100.
I have hidden the Rows 500 - 503, yet after hitting Ctrl + End, the Cursor moves to Row 499.
My requirement is after hitting Ctrl + End, the Cursor should be at the last cell of Row 100.
So, how do i do this ?
EDIT : Thanks for all the answers. Many advised me to have another sheet for non user related data, but i can't have it. Also i am not supposed to have the vba scripts.(Should have given you these conditions before... my bad!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通过更好的隔离可以解决这个问题。
也就是说,设计供用户使用的工作表应限制为仅包含用户界面所需的元素。在这种情况下,只有用户应该看到的行。
任何需要保留在并非为用户直接使用而设计的工作表中的数据都应该位于其自己的工作表上,甚至可以对用户完全隐藏。
This problem will be removed with better isolation.
That is, worksheets which are designed for use by a user should be restricted to containing only the elements necessary for the user interface. In this case, only the rows which the user is supposed to see.
Any data which needs to be persisted in worksheets which is not designed for direct user consumption should be on their own worksheets, which can even be hidden from the user completely.
当然,您问题的具体答案是:捕获 Ctrl-END 键的使用。
您可以通过在工作表中指定以下事件触发器来轻松完成此操作:
另一个模块包含
另一个满足您所描述的要求并消除观察和抑制按键的需要的可爱方法是将导航限制为第 100 行。现在是 Ctrl-END会将用户置于第 100 行的最右列,并且 Ctrl-DOWN 也会被覆盖。事实上,用户无法越过第 100 行
,但是......等等!难道真的没有办法了吗? ...当然,用户仍然可以滚动超过第 100 行并检测到您的小第 500 行复活节彩蛋。因此,我 100% 同意之前关于不同策略的建议,因为
您可能有理由实施按键抑制器,但请始终记住,用户有许多不同的方法可以绕过它,这需要非常仔细地考虑。
The specific answer to your question of course is: trap the usage of the Ctrl-END key.
You can do this easily by specifying the following event triggers to your sheet:
and another module containing
Another cute way meeting the requirements you described and eliminating the need of watching and suppressing keys would be to limit navigation to row 100. Now a Ctrl-END would place the user into the rightmost column of row 100, and Ctrl-DOWN would be covered as well. In fact the user just can't go past row 100
but .... wait !!! is there really no way? ... of course the user still may SCROLL past row 100 and detect your little row-500 easter egg. So I concur to 100% with earlier suggestions about a different strategy, because
You may have reasons to implement a key supressor, but always remember there are many different ways for the user to bypass it and this needs to be considered very carefully.
这是 Excel 的内置行为,我认为您无法更改它。建议:
That's Excel's built-in behaviour, and I don't think you can change it. Suggestions:
正如其他人所说,将非用户数据分隔在不同的工作表上当然更好。
也就是说,您可以做的一件事是保护您的工作表并禁止访问锁定的单元格,只保留用户必须在其中输入解锁内容的单元格。
这样做可以防止 CtrlEnd 执行任何操作:它无法跳转到最后一个单元格,因为它被锁定,因此它不会执行任何操作。 (在 Excel 2007 上测试)
但是,将用户数据和非用户数据分离到不同的工作表中可能会更好。
As others said it's certainly better to separate your non-user data on a different sheet.
That said, one thing you could do is protect your sheet and disallow access to locked cells, leaving only the cells in which the user has to input something unlocked.
Doing that prevents CtrlEnd from doing anything at all: it can't jump to the last cell as it is locked, so it doesn't do anything. (Tested on Excel 2007)
But again, you'll probably be better off by separating user and non-user data in different sheets.