Text in Formula

T

Tony Di Stasi

Hi,

Having problem getting text into formula:

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"" & ")"
 
H

Harlan Grove

...
...
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""" & ")"
 
Top