Inserting a formual with " in it

  • 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
 
Hi Mike,

Try doubling the internal quotes:

ActiveCell.FormulaR1C1 = "=Right(""0000"" & c3,4)"
 
I got a little closer....thanks....

now can I get past a vlookup

ActiveCell.FormulaR1C1 = "=Right(""0000"" & c3,4)&Vlookup(e3,'Bank
Lookup'$A$2:$B$8,2,False)"

I think the ' in the worksheet name is hanging me up now. The first part
worked just fine.
 
Hi Mike,

Try:

ActiveCell.Formula = "=Right(""0000"" & c3,4) & " & _
"Vlookup(e3,'Bank Lookup'!$A2:$B$8,2)"
 
Hi Mike,

I failed to include your fourth VLookup parameter, so change:
ActiveCell.Formula = "=Right(""0000"" & c3,4) & " & _
"Vlookup(e3,'Bank Lookup'!$A2:$B$8,2)"

to:

ActiveCell.Formula = "=Right(""0000"" & c3,4) & " & _
"Vlookup(e3,'Bank Lookup'!$A2:$B$8,2,False)"
 

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