Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula into cells from VBA help please!
Hi,
I want to put this formula into a cell via VBA; =IF(C4 = 5,"ACTIVATED","NOT ACTIVATED") However this would mean the code would be; range("c4").formula = "=IF(C4 = 5,"ACTIVATED","NOT ACTIVATED")" which will cause me errors because of the "" enclosed in the formula. I'd appreciate if anyone could clear this up for me. Thanks, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula into cells from VBA help please!
Range("c4").formula = "=IF(C4 = 5,""ACTIVATED"",""NOT ACTIVATED"")"
-- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "anon" wrote in message ... Hi, I want to put this formula into a cell via VBA; =IF(C4 = 5,"ACTIVATED","NOT ACTIVATED") However this would mean the code would be; range("c4").formula = "=IF(C4 = 5,"ACTIVATED","NOT ACTIVATED")" which will cause me errors because of the "" enclosed in the formula. I'd appreciate if anyone could clear this up for me. Thanks, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula into cells from VBA help please!
Quote marks delineate String constants (text) in VB, so the internal quote
marks are confusing the VB compiler. VB does provide a mechanism to include quote marks within a String... double them up. So, wherever you need a quote mark inside a String constant, use two quote marks instead of the one you would normally use. Range("c4").Formula = "=IF(C4 = 5,""ACTIVATED"",""NOT ACTIVATED"")" Note that the outer quote marks are not doubled up... they are the ones that delineate the String constant; it is only quote marks within them that need to be doubled up in order to be interpreted as a quote mark character and not a String delineater. Rick "anon" wrote in message ... Hi, I want to put this formula into a cell via VBA; =IF(C4 = 5,"ACTIVATED","NOT ACTIVATED") However this would mean the code would be; range("c4").formula = "=IF(C4 = 5,"ACTIVATED","NOT ACTIVATED")" which will cause me errors because of the "" enclosed in the formula. I'd appreciate if anyone could clear this up for me. Thanks, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorting formula cells not same as sort of value cells? Yikes! | Excel Discussion (Misc queries) | |||
Formula refers to empty cells even when cells contains data | Excel Worksheet Functions | |||
Setting of input cells as blue font and formula cells as black fon | Excel Discussion (Misc queries) | |||
trying to create an (almost) circular formula between cells and data validated cells with lists | Excel Worksheet Functions | |||
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement | Excel Programming |