vba 如何在 excel 中定义一个范围,比如 Range("B &i : C" & j)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19501018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to define a Range in excel say like Range("B &i : C" & j)
提问by Vikram
There is one table in my excel spreadsheet.
我的 Excel 电子表格中有一张表格。
So I want to start the other table from a defined range below it.
所以我想从它下面的定义范围开始另一个表。
Please help me to set a range like
请帮我设置一个范围
Excel.Application.ActiveWorkbook.Sheets(1).Range("B &i : C" & j)
回答by Siddharth Rout
.Sheets(1).Range("B" & i & ":C" & j)
Anything between "
will be treated as strings.
之间的任何内容"
都将被视为字符串。
Also if you are doing this from VBA Excel then it is no point in writing Excel.Application
. It is understood by default.
此外,如果您是从 VBA Excel 执行此操作,那么编写Excel.Application
. 默认是理解的。
Also if you want the range from the workbook from where the code is run then you don't need Activeworkbook
You can use ThisWorkbook
Reason being It's not necessary that both will be same at all times.
此外,如果您想要运行代码的工作簿中的范围,那么您不需要Activeworkbook
您可以使用ThisWorkbook
Reason 不需要两者始终相同。
Set Rng = ThisWorkbook.Sheets(1).Range("B" & i & ":C" & j)