简体   繁体   English

使用 VBA 插入公式

[英]Insert formula using VBA

The below vba code fails to insert the formula into the cell.下面的 vba 代码无法将公式插入单元格。 Cell E3 contains 25,208.70 - 15,685.60.单元格 E3 包含 25,208.70 - 15,685.60。 Expected outcome is 25,208.70.预期结果为 25,208.70。 I do get the expected answer if the formula is inserted into the cell BJ3 but fails to insert the formula using VBA.如果将公式插入单元格 BJ3 但无法使用 VBA 插入公式,我会得到预期的答案。

Please help!请帮忙!

Range("BJ3").Formula = "=VALUE(TRIM(LEFT(E3, FIND(" - ", E3) - 1)))"

Please, try:请试试:

Range("BJ3").Formula = "=VALUE(TRIM(LEFT(E3, FIND("" - "", E3) - 1)))"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM