在Excel VBA中正确编写公式 [英] Write properly a formula in Excel VBA

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

问题描述

我以前已经问过这样的问题,但是似乎给出的答案在这种情况下不起作用

I already asked a question like this before, but seems that the answer given is not working in this case

这是我的代码:

Worksheets("Sheet").Range(myRange).formula = "=CONCATENATE(CODICI!" & stringCodiceCella & ";" & stringDesignazioneCella & ")"

请注意,stringCodiceCella是一个字符串,stringDesignazioneCella也是一个字符串.

Note that stringCodiceCella is a String, and stringDesignazioneCella is also a String.

点击此链接 VBA中公式的有效示例

我看不到错误.

推荐答案

您可以使用,"代替;"如@BigBen

You can use "," in place of ";" as suggested by @BigBen

Worksheets("Sheet").Range(myRange).Formula = "=CONCATENATE(CODICI!" & stringCodiceCella & "," & stringDesignazioneCella & ")"

或使用FormulaLocal

Worksheets("Sheet").Range(myRange).FormulaLocal = "=CONCATENATE(CODICI!" & stringCodiceCella & ";" & stringDesignazioneCella & ")"

参见下面的代码.

Worksheets("Sheet").Range(myRange).Formula = "=CONCATENATE(CODICI!" & stringCodiceCella & ",""-""," & stringDesignazioneCella & ")"

Worksheets("Sheet").Range(myRange).FormulaLocal = "=CONCATENATE(CODICI!" & stringCodiceCella & ";""-"";" & stringDesignazioneCella & ")"

这篇关于在Excel VBA中正确编写公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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