Excel(2007)VBA - .Formula中有引号 [英] Excel (2007) VBA - .Formula with quotes in it

查看:228
本文介绍了Excel(2007)VBA - .Formula中有引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天尝试将以下代码放入程序中。 VBA称为错误。我认为这是因为公式中的双引号。我已经搜索到了所有的结果,只是给出了放置公式的基本原理,但是没有一个解释如何解决报价。

I tried putting the following code into a program yesterday. VBA called an error. I assume it is because of the double quotes inside the formula. I googled and all results I found just gave the basic of putting formulas in, but none explained how to get around quotes inside.

(之前有一个With语句, Pivot是一个工作表名称)

(there was a With statement before this, Pivot is a worksheet name)

.Range("A2").Formula = "=IF(Pivot!A5="",A1,Pivot!A5)" 

任何帮助都非常感激。谢谢!

Any help is much appreciated. Thanks!

推荐答案

每当有疑问,记录一个宏,如果它允许:)

Whenever in doubt, record a macro if it allows :)

尝试这个

.Range("A2").Formula = "=IF(Pivot!A5="""",A1,Pivot!A5)" 

这篇关于Excel(2007)VBA - .Formula中有引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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