简体   繁体   中英

Write properly a formula in Excel VBA

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.

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 & ")"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM