Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2006

Tip: Looking for answers? Try searching our database.

Inserting a VB formula with a quote problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mbt6 - 07 Jan 2006 08:38 GMT
I want to insert a formula into a specific cell, something like

ActiveCell.FormulaR1C1 =  "=EOMONTH (Now(), -1)"

This works fine and gives me the last day of last month.

But this doesn't work because of the "

ActiveCell.FormulaR1C1 =  "=Right("0000"&c3,4)"

The formula has quotes in it, and the VB chokes as it expects only one set
of quotes.

--mike
Ron Rosenfeld - 07 Jan 2006 11:09 GMT
>I want to insert a formula into a specific cell, something like
>
[quoted text clipped - 10 lines]
>
>--mike

Double the quotes within the formula.

Also, if you are going to use the FormulaR1C1 property, you MUST use the R1C1
type of reference within the formula.

For example:

ActiveCell.FormulaR1C1 = "=Right(""0000"" & r3c3,4)"

--ron
Bob Phillips - 07 Jan 2006 11:57 GMT
or use A1

ActiveCell.Formula = "=Right(""0000""&C3,4)"

Signature

HTH

Bob Phillips

(remove nothere from email address if mailing direct)

> >I want to insert a formula into a specific cell, something like
> >
[quoted text clipped - 21 lines]
>
> --ron
Ron Rosenfeld - 07 Jan 2006 13:47 GMT
>or use A1
>
>ActiveCell.Formula = "=Right(""0000""&C3,4)"

Many ways to skin a cat in Excel!
--ron
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.