Solved

VBA Syntax

Posted on 2011-02-10
6
300 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
ID: 34864539
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
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"")"
0
 
LVL 81

Expert Comment

by:byundt
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
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 37

Expert Comment

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

Expert Comment

by:SiddharthRout
ID: 34864754
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
ID: 34864797
awesomejohn19: Thank you for the points but I feel the points should have been equally distributes amongst us :)

Sid
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

820 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