How to plug a range object into a formula

后端 未结 2 1714
刺人心
刺人心 2021-01-19 17:32

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\")         


        
相关标签:
2条回答
  • 2021-01-19 18:04

    You need

    Range("C1").Formula = "=SUM(" & x.Address(False, False) & ")"
    

    See also

    http://www.dailydoseofexcel.com/archives/2004/04/16/worksheet-formulas-in-vba-part-i/

    http://www.dailydoseofexcel.com/archives/2004/04/16/worksheet-formula-in-vba-part-ii/

    0 讨论(0)
  • 2021-01-19 18:14

    Use x.address, that should do the trick

    0 讨论(0)
提交回复
热议问题