Write properly a formula in Excel VBA

不打扰是莪最后的温柔 提交于 2020-04-17 21:40:30

问题


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

this is my code:

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

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

Following this link A working example of formula in VBA

I can't see the error.


回答1:


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

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

Or use FormulaLocal

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

Edit: See below code.

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

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



来源:https://stackoverflow.com/questions/60095600/write-properly-a-formula-in-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!