Text quote marks in Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If have a macro which is to replace a formula in a cell where the operator
has the option of either accepting the formula result as a default or
overtyping with a different value. A "Reset" button runs the macro that
restores the formula into the cell.
The line that does this is ..
Range("New_Sec") = "=If(Purpose_1="Upstamp",0,1)"

The obvious problem is that the Macro needs to see the formula as a string
so that it can be put back into the cell, so it is enclosed in quotes, and
the formula needs to have "Upstamp" defined as a string, so it also is
enclosed in quotes and the two sets of quotes causes an error.

What is the solution for this?
 
Double them, just as in XL:

Range("New_Sec") = "=If(Purpose_1=""Upstamp"",0,1)"
 

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