Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB Macro writing a formula to a cell
If you use quotes within another set of quotes you need to double up so:
Sub Formula_Test() Application.ScreenUpdating = True Range("L17").Formula = "=IF(F170,INT(F15/F17),"""")" End Sub Regards Rowan Neal Zimm wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB Macro writing a formula to a cell
It was late at night, thanks, i really did know that but didn't connect the
dots. thanks again. -- Neal Z "Rowan" wrote: If you use quotes within another set of quotes you need to double up so: Sub Formula_Test() Application.ScreenUpdating = True Range("L17").Formula = "=IF(F170,INT(F15/F17),"""")" End Sub Regards Rowan Neal Zimm wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need help writing Excel macro to solve a cell in each row of a spreadsheet | Excel Programming | |||
Writing a macro to copy first cell down until next cell has data | Excel Programming | |||
When writing a macro in excel workbook, how do I refer to ea cell | Excel Programming | |||
I need help writing a macro to replace cell contents. (new to VB) | Excel Programming | |||
Writing variable from a Macro to a Cell | Excel Programming |