Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I see from the Excel help that you can set formulas, but when I tried to set the following formula: Worksheets("Sheet1").Range("A1").Formula = "=+IF(B1 < "",(B1-1)*1000 + (1000-C1),"")" it didn't work? I get run-time error 1004 "Application defined or object defined error" Any ideas? Thanks in advance, Reedi |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First, ditch the =+. That marks you as a Lotus-holdout.
The problem you're having is that quotation marks in VBA designate the start and end of a string of text. To refer to quotation marks *within* a string of text, you need to double them (""): Worksheets("Sheet1").Range("A1").Formula = _ "=IF(B1< """", (B1-1)*1000+(1000-C1), """")" which could be more simply written: Worksheets("Sheet1").Range("A1").Formula = _ "=IF(B1< """", B1 * 1000 - C1, """")" In article , "Reedi" wrote: Hi, I see from the Excel help that you can set formulas, but when I tried to set the following formula: Worksheets("Sheet1").Range("A1").Formula = "=+IF(B1 < "",(B1-1)*1000 + (1000-C1),"")" it didn't work? I get run-time error 1004 "Application defined or object defined error" Any ideas? Thanks in advance, Reedi |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
converting formulas to code | New Users to Excel | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
delete some cell formulas and leave others using code | Excel Worksheet Functions | |||
Code to delete rows and column cells that have formulas in. | Excel Worksheet Functions | |||
Copy formulas via Code | Excel Discussion (Misc queries) |