开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜