Thread: Text in Formula
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Harlan Grove[_5_] Harlan Grove[_5_] is offline
external usenet poster
 
Posts: 97
Default Text in Formula

"Tony Di Stasi" wrote...
...
Need to have the following formula in cell(1):

=if(b1="B", "", "Match")

The following code does not work:

Cells(1).formula= "=if(" & Cells(2).address & "=" & ""B"" & _
"," & """" & "," & ""Match"" & ")"


A few things. If you want B1 rather than $B$1, add some parameters to that
Address call - Cells(2).Address(0, 0). Aside from that, you're not doubling your
embedded double quotes. To get "" as a result, you need to start with """"""
rather than """". So try

Cells(1).Formula= "=IF(" & Cells(2).Address(0, 0) & "=" & """B""" & _
"," & """""" & "," & """Match""" & ")"

--
Never attach files.
Snip unnecessary quoted text.
Never multipost (though crossposting is usually OK).
Don't change subject lines because it corrupts Google newsgroup archives.