View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
YouWontSpamThisAdress YouWontSpamThisAdress is offline
external usenet poster
 
Posts: 3
Default Put a formula in a Cell through VBA

Hi Rick,

That is what I did... the cut-paste indicated is the result in the actual
cell...

This is my actual code :
formula = "=IF(E" & CurRow & "=""< 0.005"",0.0025,IF(F" & CurRow & "0,F" &
CurRow & " , E" & CurRow & "))"

Thanks

"Rick Rothstein" a écrit dans le
message de news: ...
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.