Syntax for writing a formula to a cell

  • Thread starter Thread starter Guy Hoffman
  • Start date Start date
G

Guy Hoffman

I am attempting to write this formula to a cell from VBA:

Worksheets("Summary").Range("H18").Formula = "=cell("contents",b53)"

But because the worksheet formula also uses double quotes as part of
its syntax, I am getting a compile error as VBA thinks the second
double quote (next to the word "cell" is the end of the statement.

I tried using a single quote but to no avail.

How do you fix this?

GH
 
Replace each double quote by a pair of double quotes.
I discovered this by recording a macro that performed the operation you
asked about.
Bernard
 
Use double quotes, i.e.

Worksheets("Summary").Range("H18").Formula = "=cell(""contents"",b53)"
 
Guy,

Try this

Worksheets("Summary").Range("H18").Formula = "=cell(""contents"",b53)"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top