将公式与行数连接起来
Concatenate formula with rowcount
我正在尝试在带有 VBA 的单元格中输入 CONCATENATE
公式。但它写入的结果一直返回 false...我需要使用行数,因为 table 变长了,我需要它用于那一行。
这是我试过的最新代码,还是没有用:
.Offset(RowCount, 0) = Formula = "=CONCATENATE(P" & RowCount & "J" & RowCount & "DG" & RowCount
如有任何建议,我们将不胜感激。
您没有正确创建字符串,您需要将 = Formula =
更改为 .Formula =
。另外,我假设 RowCount
是在某处定义的?
变化:
.Offset(RowCount, 0) = Formula = "=CONCATENATE(P" & RowCount & "J" & RowCount & "DG" & RowCount
收件人:
.Offset(RowCount, 0).Formula = "=CONCATENATE(P" & RowCount & ",J" & RowCount & ",DG" & RowCount & ")"
您也可以改用 R1C1 寻址:
.Offset(RowCount, 0).FormulaR1C1 = "=CONCATENATE(R[-1]C16,R[-1]C10,R[-1]C111)"
我正在尝试在带有 VBA 的单元格中输入 CONCATENATE
公式。但它写入的结果一直返回 false...我需要使用行数,因为 table 变长了,我需要它用于那一行。
这是我试过的最新代码,还是没有用:
.Offset(RowCount, 0) = Formula = "=CONCATENATE(P" & RowCount & "J" & RowCount & "DG" & RowCount
如有任何建议,我们将不胜感激。
您没有正确创建字符串,您需要将 = Formula =
更改为 .Formula =
。另外,我假设 RowCount
是在某处定义的?
变化:
.Offset(RowCount, 0) = Formula = "=CONCATENATE(P" & RowCount & "J" & RowCount & "DG" & RowCount
收件人:
.Offset(RowCount, 0).Formula = "=CONCATENATE(P" & RowCount & ",J" & RowCount & ",DG" & RowCount & ")"
您也可以改用 R1C1 寻址:
.Offset(RowCount, 0).FormulaR1C1 = "=CONCATENATE(R[-1]C16,R[-1]C10,R[-1]C111)"