![]() |
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, |
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, |
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, |
All times are GMT +1. The time now is 07:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com