View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Neal Zimm Neal Zimm is offline
external usenet poster
 
Posts: 345
Default VB Macro writing a formula to a cell

I have a macro which is writing formulas to cells.
lines like: Range("D19").Formula = "=SUM(J23:J75)" work fine.

I am getting stuck on IF statements like the one below and
isolated it into the Formula_Test macro to 'play with'.

The facts a
L17 is general format cell.
The formula works fine in the worksheet when entered by hand.
Appropriate values are in F15 and F17.
The worksheet is NOT protected for this test.
I get a 1004 run time error when I run the macro.
The "If" help via function F1 key in Excel was little
help. I know the syntax of the formual is OK 'cuz it
works when entered by hand into L17.

Sub Formula_Test()
Application.ScreenUpdating = True
Range("L17").Formula = "=IF(F170,INT(F15/F17),"")"
End Sub

I don't know what to try or where to look next.
Help.
Thanks.
Neal Z