问题
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