如何将范围对象插入公式 [英] How to plug a range object into a formula

查看:57
本文介绍了如何将范围对象插入公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将范围对象插入公式中.一个示例应大致如下:

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

结果应为单元格C1中的"= SUM(A1:A2)".

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

重点是将范围对象插入公式中.我以SUM为例,实际公式更加复杂.

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 ...

预先感谢, 黛妮斯

推荐答案

您需要

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

另请参见

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/

这篇关于如何将范围对象插入公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆