问题描述
对于Range("B1:U" & y)
的含义是什么,我一无所知
Im clueless on what the meaning of Range("B1:U" & y)
is where y is
Dim y As Integer
y = Worksheets("Raw Data").Range("A2").End(xlDown).Row
&"号在这里做什么?
What is the ampersand y doing here?
推荐答案
在基于Visual Basic的语言(例如VBA)中,&符是Concatenation运算符,在您的情况下,您使用字符串"B1:U"并连接值变量y到字符串末尾.由于y定义为Integer,因此VBA将首先将y的值转换为字符串,然后执行串联.例如,如果y的值是15,则因为y是工作表原始数据"上范围"A2"中的最后一个单元格,则"B1:U"和"A"的串联将被合并. y为"B1:U15"
The ampersand is the Concatenation operator in the Visual Basic based languages, like VBA, in your case you are taking the string "B1:U" and concatenating the value of the variable y to the end of the string. Since y is defined as an Integer, VBA will first convert the value of y to a string and then perform the concatenation. For Example, if the value of y is 15, since that is the last cell in the range "A2" on the worksheet "Raw Data" then the concatenation of "B1:U" & y would be "B1:U15"
这篇关于VBA范围内“&"号的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!