Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Text in a Formula or FormulaR1C1 property

I want to use a logical if statement checking a text word in a formula
statement.

I want programmatically to create the cell
=IF(A1="apples","Yes","No")

However, when I enter
Range("B1").Formula="=IF(A1="apples","Yes","No")"

in VB the quotes mess this all up. The single quotes don't work either
Range("B1").Formula="=IF(A1='apples','Yes','No')"

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Using Text in a Formula or FormulaR1C1 property

Double up the double quotes:

Sub dural()
s = "=IF(A1=""apples"", ""yes"",""no"")"
Range("B1").Formula = s
End Sub

--
Gary''s Student - gsnu200840


"Turtle_Todd" wrote:

I want to use a logical if statement checking a text word in a formula
statement.

I want programmatically to create the cell
=IF(A1="apples","Yes","No")

However, when I enter
Range("B1").Formula="=IF(A1="apples","Yes","No")"

in VB the quotes mess this all up. The single quotes don't work either
Range("B1").Formula="=IF(A1='apples','Yes','No')"

Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Text in a Formula or FormulaR1C1 property

works great, thanks

"Gary''s Student" wrote:

Double up the double quotes:

Sub dural()
s = "=IF(A1=""apples"", ""yes"",""no"")"
Range("B1").Formula = s
End Sub

--
Gary''s Student - gsnu200840


"Turtle_Todd" wrote:

I want to use a logical if statement checking a text word in a formula
statement.

I want programmatically to create the cell
=IF(A1="apples","Yes","No")

However, when I enter
Range("B1").Formula="=IF(A1="apples","Yes","No")"

in VB the quotes mess this all up. The single quotes don't work either
Range("B1").Formula="=IF(A1='apples','Yes','No')"

Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Using Text in a Formula or FormulaR1C1 property

Dim strTemp
Dim strValue

strValue = "Apple"

strTemp = "=IF(A1=""" & strValue & """,""yes"",""no"")"
Range("B1").Formula = strTemp

If this post helps click Yes
--------------
Jacob Skaria
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
How to refer to the .text property without text box name? Yajiv Excel Programming 1 February 26th 08 03:09 PM
FormulaR1C1 v Formula Smallweed Excel Programming 1 October 1st 07 03:49 PM
Excel VBA: Worksheet cell .Text property: 1024 bytes text len limit loyso Excel Programming 7 May 3rd 05 02:51 PM
Need help with FORMULAR1C1 property John Wirt[_5_] Excel Programming 2 February 10th 05 03:46 AM
Value Property vs Text property augustus Excel Programming 3 October 31st 04 10:32 PM


All times are GMT +1. The time now is 11:58 PM.

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

About Us

"It's about Microsoft Excel"