View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Put a formula in a Cell through VBA

If you assign the string representation of your formula to the Formula
property of the cell and double up the internal quotes so VB sees them as a
quote character instead of a String delimiter, it should work. Here is an
example...

Range("A1").Formula="=IF(E7281=""<0.005"",0.0025,I F(F72810,F7281,E7281))"

Notice that I have used 2 quote marks where there will be 1 quote mark
showing in the formula itself.

--
Rick (MVP - Excel)


"YouWontSpamThisAdress" wrote in
message ...
Hi,

I'm trying to put a formula in a cell with my VBA function. The resulting
formula doesn't work, it gives me #NAME? error.

A working formula:

=IF(E7281="<0.005",0.0025,IF(F72810,F7281,E7281))

One put from my VBA function :

=IF(E7292="<0.005",0.0025,IF(F72920,F7292,E7292))

If I simply double-click on the error cell, without editing anything, the
formula works after.

Thanks.