Inserting a VB formula with a quote problem

  • Thread starter Thread starter Mbt6
  • Start date Start date
M

Mbt6

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
 
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

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
 
or use A1

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

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top