Link to home
Start Free TrialLog in
Avatar of A G
A GFlag for United States of America

asked on

VBA Syntax

ActiveCell.Offset(i, 5).Formula = ("=Text(" & ActiveCell.Offset(i, 0).Value & "," & ""mmddyy"" & ")")

I have the following line . I get an error highlighting mmddyy and it says "Expected )"

How can I correct this?
Avatar of SiddharthRout
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TommySzalapski
You need to use double quotes for every quote mark that you actually want. So your line needs to be
ActiveCell.Offset(i, 5).Formula = "=Text(" & ActiveCell.Offset(i, 0).Value & ",""mmddyy"")"
ActiveCell.Offset(i, 5).Formula = "=Text(" & ActiveCell.Offset(i, 0).Value & "," & """mmddyy""" & ")"

You need to use three double quotes before and after mmddyy to get one double quote to appear in the actual formula
You can split them all apart separately as in Sid's solution, but this should not be needed.
By double quotes, I meant two double quotes (or double double quotes). Anyway = "AA""A" will translate to AA"A.
You are right Tommy. I deliberately split them so that OP can understand every part of it. :)

awesomejohn19: Thank you for the points but I feel the points should have been equally distributes amongst us :)