Text quote marks in Macro

K

Ken G.

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

JE McGimpsey

Double them, just as in XL:

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