Swati
Swati

Reputation: 23

Entering formula in vba with text

I am trying to write a formula in vba excel but it is returning with error #name but without text formula is working fine. May be there syntax error. Can anybody help me to solve this Formula is below

Range("AQ4").Formula = "=Due for Promotion to E2A Level w.e.f.&DATE(YEAR(AP4)+1,MONTH(AP4),DAY(AP4))"

Upvotes: 2

Views: 5934

Answers (1)

Scott Craner
Scott Craner

Reputation: 152505

The text needs to be surrounded by "":

Range("AQ4").Formula = "=""Due for Promotion to E2A Level w.e.f."" & TEXT(DATE(YEAR(AP4)+1,MONTH(AP4),DAY(AP4)),""dd-mm-yyy"")"

Upvotes: 3

Related Questions