开发者

on vb/vba .passing variables as arguments to an object property like .rows

开发者 https://www.devze.com 2023-03-05 00:45 出处:网络
I want to use the following piece of code but it won\'t let me, the error: \"expected: list separator or )\":

I want to use the following piece of code but it won't let me, the error: "expected: list separator or )":

a = 1: b = 13
activesheet.rows(a:b)

why can't I pass the a and b variables to开发者_如何学运维 the property like for example: activesheet.rows("1:3").- when I use the "a:b" format it gives me "run-time error 1004" application defined ot object defined error.


You need to create a string containing the values of a and b.

ActiveSheet.Rows(CStr(a) & ":" & CStr(b))


You need to use the Range method:

ActiveSheet.Range(ActiveSheet.Rows(a), ActiveSheet.Rows(b))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号