Solved

VBA Syntax

Posted on 2011-02-10
6
297 Views
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?
0
Comment
Question by:awesomejohn19
  • 3
  • 2
6 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
Comment Utility
Try this

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

Open in new window


Sid
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
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"")"
0
 
LVL 80

Expert Comment

by:byundt
Comment Utility
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
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
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.
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
You are right Tommy. I deliberately split them so that OP can understand every part of it. :)

Sid
0
 
LVL 30

Expert Comment

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

Sid
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now