Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting formula cells not same as sort of value cells? Yikes! Barn E. Fife Excel Discussion (Misc queries) 4 October 13th 11 08:35 PM
Formula refers to empty cells even when cells contains data Monica Rustogi Excel Worksheet Functions 1 February 25th 10 06:56 PM
Setting of input cells as blue font and formula cells as black fon Sunnyskies Excel Discussion (Misc queries) 2 May 14th 07 05:27 PM
trying to create an (almost) circular formula between cells and data validated cells with lists KR Excel Worksheet Functions 0 May 12th 05 07:21 PM
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement Kevin Excel Programming 7 October 5th 04 08:11 PM


All times are GMT +1. The time now is 01:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"