ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   String of data in a cell. Want to use 'contains' in an 'if' statem (https://www.excelbanter.com/excel-discussion-misc-queries/130627-string-data-cell-want-use-contains-if-statem.html)

Andrew

String of data in a cell. Want to use 'contains' in an 'if' statem
 
Is there a way of writing the following?

=if ( cell 'contains' x , then write "y" , else write "n" )
The cell contains text.

Suggestions appreciated, thanks.

Gary''s Student

String of data in a cell. Want to use 'contains' in an 'if' statem
 
Hi Andrew:

If InStr(cellvalue,x)0 Then
MSGBOX("Y")
else
MSGBOX("N")
endif


--
Gary's Student
gsnu200705


"Andrew" wrote:

Is there a way of writing the following?

=if ( cell 'contains' x , then write "y" , else write "n" )
The cell contains text.

Suggestions appreciated, thanks.


Bob Phillips

String of data in a cell. Want to use 'contains' in an 'if' statem
 
=IF(ISNUMBER(FIND("x",A1)),"y","n")

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Andrew" wrote in message
...
Is there a way of writing the following?

=if ( cell 'contains' x , then write "y" , else write "n" )
The cell contains text.

Suggestions appreciated, thanks.




Ron Coderre

String of data in a cell. Want to use 'contains' in an 'if' statem
 
Try something like this:

For a value (or blank) in A1

This formula tests if A1 contains the letter "x"
B1: =IF(COUNTIF(A1,"*x*"),"y","n")


Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Andrew" wrote:

Is there a way of writing the following?

=if ( cell 'contains' x , then write "y" , else write "n" )
The cell contains text.

Suggestions appreciated, thanks.



All times are GMT +1. The time now is 06:46 PM.

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