简体   繁体   English

如何在 excel VBA 中查找活动单元格范围

[英]How to find active cells range in excel VBA

I am trying to open multiple webpage tab from my selected cells.我正在尝试从我选择的单元格中打开多个网页选项卡。 I would like to find the selected cell (based on the mouse) starting and ending row and column information for further use of vba macro.我想找到所选单元格(基于鼠标)的开始和结束行和列信息,以便进一步使用 vba 宏。

Thanks in advance...提前致谢...

You can do this:你可以这样做:

x = ActiveCell.Address
MsgBox (x)

but really, you should try to avoid using selection where possible.但实际上,您应该尽可能避免使用选择。 The reason for this is because users can (and I've found, will) click in to other spreadsheets as the code is running and so what you have intended as the selection, may no longer be the actual selection.这样做的原因是因为用户可以(我发现,将)在代码运行时单击其他电子表格,因此您打算作为选择的内容可能不再是实际选择。 It also affects the longevity of the code because it's much more difficult to fix if something breaks.它还会影响代码的寿命,因为如果出现问题,修复起来会更加困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM