在VBA中包含公式内的引号的文本 [英] Including text with quotes within a formula in VBA

查看:567
本文介绍了在VBA中包含公式内的引号的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮编码,可以在VBA中重新设置以下行的电子表格: -

I have a button coded to reset a spreadsheet with the following line in VBA:-

Range("F6") = "=IF(AND(vtype=TRUE,U41>0,vatable=FALSE),vatrate*100&"% VAT",IF(AND(vtype=TRUE,matchnew>1,vatable=TRUE),"VAT Exempt",""))"  

当此按钮被点击时出现错误,它表示标志是非法字符。

When this button is clicked an error appears, it says that the % sign is an illegal character.

请指教什么是不正确的。

Please advise what is incorrect.

推荐答案

作为测试,我命名了一个单元格vatrate,然后将 = vatrate * 100&%V VAT在另一个单元格中,它评估没有问题。

As a test, I named a cell 'vatrate', then put =vatrate*100&"%V VAT" in another cell and it evaluated with no problem.


  1. 将光标放在单元格中,该公式为

  2. 点击功能区上的公式

  3. 在功能区的公式审核部分,点击评估公式



    这将允许您一次通过您的公式一个评估,以便您可以准确地查看什么Excel看到,因为它评估它。这将告诉你这是怎么回事。

That will allow you to walk through your formula one evaluation at a time so you can see exactly what Excel's seeing as it's evaluating it. That will tell you where it's going wrong.

这篇关于在VBA中包含公式内的引号的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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