当公式随着行的增加而不断变化时,如何将公式插入单元格? [英] How do I insert the formula into the cell when the formula keeps changing with an increase in row?

查看:591
本文介绍了当公式随着行的增加而不断变化时,如何将公式插入单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在第P列的第二行输入了这些公式:

  =(COUNTIF(A $ 1: A2)= 0)+(COUNTIF(B $ 1:B1,B2)= 0)+(COUNTIF(F $ 1:F1,F2)= 0)

当我将它拖到第P列的第三行时,它就像这样:

  =(COUNTIF(A $ 1:A2,A3)= 0)+(COUNTIF(B $ 1:B2,B3)= 0)+(COUNTIF(F $ 1:F2,F3)= 0)

这是我手动做的。如何使用VBA?我已经尝试了下面的方式。

  cells(Count,M)。formula ==(COUNTIF(A $ 1 :A1,A2)= 0)+(COUNTIF(B $ 1:B1,B2)= 0)+(COUNTIF(F $ 1:F1,F2)= 0)
pre>

但它不工作。它不是从

 =(COUNTIF(A $ 1:A1,A2)= 0)+(COUNTIF(B $ 1: B1,B2)= 0)+(COUNTIF(F $ 1:F1,F2)= 0)

($ A $ 1:A2,A3)= 0)+(COUNTIF(B $ 1:B2, B3)= 0)+(COUNTIF(F $ 1:F2,F3)= 0)

当公式随着行的增加而不断变化时,将公式插入单元格?

解决方案

您可以在一个行:

 范围(P2)复制目的地:=范围(P3:P10)

不需要变量,循环,任何东西!


I have entered these formula in the second row of the Pth column:

=(COUNTIF(A$1:A1,A2)=0)+(COUNTIF(B$1:B1,B2)=0)+(COUNTIF(F$1:F1,F2)=0)

When I drag it to the third row of the Pth column, it gets like this:

 =(COUNTIF(A$1:A2,A3)=0)+(COUNTIF(B$1:B2,B3)=0)+(COUNTIF(F$1:F2,F3)=0)

This is what I do manually. How do I make it using VBA? I have tried in the way below.

cells(Count,"M").formula= "=(COUNTIF(A$1:A1,A2)=0)+(COUNTIF(B$1:B1,B2)=0)+(COUNTIF(F$1:F1,F2)=0)"

But it's not working. It's not changing from

"=(COUNTIF(A$1:A1,A2)=0)+(COUNTIF(B$1:B1,B2)=0)+(COUNTIF(F$1:F1,F2)=0)" 

to

"=(COUNTIF(A$1:A2,A3)=0)+(COUNTIF(B$1:B2,B3)=0)+(COUNTIF(F$1:F2,F3)=0)"

How do I insert the formula into the cell when the formula keeps changing with an increase in row?

解决方案

You can do this in one line:

range("P2").Copy Destination:=range("P3:P10")

No need for variables, loops, anything!

这篇关于当公式随着行的增加而不断变化时,如何将公式插入单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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