Excel宏将公式结果写入单元格 [英] Excel Macro to write a formula result to a cell
本文介绍了Excel宏将公式结果写入单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何在MACRO中将公式写入单元格,但是我需要将此公式的输出写入单元格
I know how to write a formula to cell in a MACRO, but i need to write the output of this formula to the cell
Rng.Offset(0, 1).Formula = "=CONCATENATE(IF(RC[-1]<>"""",RC[-2]& _ MID(CELL(""filename"",RC),FIND(""]"",CELL(""filename"",RC))+1,256),""""),""_"",RC[-1])"
不使用
Rng.Offset(0, 1).Copy
Rng.Offset(0, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False
推荐答案
我总是只用当前值覆盖单元格的值,例如:
I always just overwrite the value of the cell with its current value, so for example:
Rng.Offset(0, 1).Formula = "=CONCATENATE(IF(RC[-1]<>"""",RC[-2]& _
MID(CELL(""filename"",RC),FIND(""]"",CELL(""filename"",RC))+1,256),""""),""_"",RC[-1])"
Rng.Offset(0, 1).Value = Rng.Offset(0, 1).Value
这会将公式从单元格中删除,并简单地将其替换为公式计算出的值.
This will remove the formula from the cell and simply replace it with the value calculated by the formula.
这篇关于Excel宏将公式结果写入单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文