单张/范围选择(组合)不工作 [英] Sheet / Range Select (combined) not working
问题描述
- 问题简单的例子:
当我使用以下代码,它可以正常工作。
范围(B3)选择
当我结合它们时,我得到一个1004错误
表格(Sheet1)。范围(B3)选择
我查看了参考/文档库,在这里没有任何改变。它必须是简单的,但我只是不能把我的手指。
如果你绝对必须在单行代码中执行此操作,然后交换Select for a Application.GoTo
,它接受工作表和单元格范围。
application.goto range(Sheet1!B3)
然而,几乎从来没有必要(最常见的是反效果)使用 Range。选择方法来引用要处理的单元格或单元格。请参阅如何避免在Excel VBA宏中使用选择以避免依赖选择和激活来实现您的目标。
Something has changed in my VBA that is not allowing me to complete certain routines. I have listed a very simple example below. If anyone has experienced this I would be really appreciate any support in resolving this issue.
- Simple example of issue:
When I use the following code it works fine.
Sheets("Sheet1").Select
Range("B3").Select
When I combine them I get a "1004" error
Sheets("Sheet1").Range("B3").Select
I checked the reference/document library and nothing appears to have changed in here. It has to be something simple but I just can't put my finger on it.
If you absolutely must do it in a single line of code then swap the Select for an Application.GoTo
which accepts both worksheet and cell range.
application.goto range("Sheet1!B3")
However, it is almost never necessary (and most often counter-productive) to use the Range .Select method to reference a cell or cells to work on. See How to avoid using Select in Excel VBA macros for methods on getting away from relying on select and activate to accomplish your goals.
这篇关于单张/范围选择(组合)不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!