How to plug a range object into a formula

2020-04-09 23:58发布

I want to plug a range object into a formula. An example should look roughly like this:

Dim x As Range
Set x = Range(Cells(1, 1), Cells(2, 1))

Range("C1").Formula = "=SUM(" & x & ")"

The result should be "=SUM(A1:A2)" in cell C1.

The point is to plug the the range object into a formula. I used SUM as an example, the real formula is more complicated.

I guess there is an easy answer to this, e.g. some method for a range object, but I have't found it after some pondering ...

Thanks in advance, Dainis

2条回答
地球回转人心会变
2楼-- · 2020-04-10 00:23

Use x.address, that should do the trick

查看更多
登录 后发表回答