Warning: file_put_contents(/datas/wwwroot/jiajiahui/core/caches/caches_template/2/default/show.php): failed to open stream: Permission denied in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 55

Warning: chmod(): Operation not permitted in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 56
Excel VBA:如何将公式插入到单元格区域? - 源码之家

Excel VBA:如何将公式插入到单元格区域?

问题描述:

问题Excel VBA:如何将公式插入到单元格区域?

我需要插入一些公式到VBA单元格的2维区域。例如低于

Excel Range sample

我当然可以为1行做到这一点与使用.Formulas =“= SUM(....)”

VBA但如何可以包括区域代替只是一个范围?这似乎很琐碎,但我似乎无法弄清楚。我试图避免使用循环来填充每一行。

+1

定义你所说的 “范围” 的意思是什么,按“区域”。我怀疑你只是用两个不同的名字来混淆你自己,这个名字真的是一回事...... –

Range("yourrange").Formula = "=Sum(whatever)" 

其中yourrange是一个命名范围,或为实际参考

Range("A1:F8").Formula = "=Sum(whatever)" 

range("A1:G10").formula = "=Sum(H1:H10)"

填你自己的范围/公式