ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text in Formula (https://www.excelbanter.com/excel-programming/286422-text-formula.html)

Tony Di Stasi

Text in Formula
 
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"" & ")"

Harald Staff

Text in Formula
 
Hi

"=if(" & Cells(2).Address & "=B,"""",""Match"")"

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Tony Di Stasi" skrev i melding
...
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"" & ")"




Harlan Grove[_5_]

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.


All times are GMT +1. The time now is 01:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com