VBA Syntax

Posted on 2011-02-10
Last Modified: 2012-05-11
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?
Question by:awesomejohn19
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 30

Accepted Solution

SiddharthRout earned 500 total points
ID: 34864539
Try this

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

Open in new window

LVL 37

Expert Comment

ID: 34864705
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"")"
LVL 81

Expert Comment

ID: 34864718
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

LVL 37

Expert Comment

ID: 34864740
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.
LVL 30

Expert Comment

ID: 34864754
You are right Tommy. I deliberately split them so that OP can understand every part of it. :)

LVL 30

Expert Comment

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


Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question