ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   String Contains a Value (https://www.excelbanter.com/excel-programming/371041-string-contains-value.html)

Lynn

String Contains a Value
 
I would like a certain action to be carried out if a specified string is
found anywhere within the active cell. What code can I use to evaluate the
condition?

Eg if Customer is found anywhere in the active cell, I want to delete the
current row.

Tom Ogilvy

String Contains a Value
 
if instr(1,cell.Value,"ABC",vbTextcompare) then
cell.EntireRow.Delete
end if

--
Regards,
Tom Ogilvy


"Lynn" wrote:

I would like a certain action to be carried out if a specified string is
found anywhere within the active cell. What code can I use to evaluate the
condition?

Eg if Customer is found anywhere in the active cell, I want to delete the
current row.


Bob Phillips

String Contains a Value
 
If ACtivecell.Value Like "*name*" Then
ACtivecell.Entirerow.Delete
End If

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lynn" wrote in message
...
I would like a certain action to be carried out if a specified string is
found anywhere within the active cell. What code can I use to evaluate

the
condition?

Eg if Customer is found anywhere in the active cell, I want to delete the
current row.




Lynn

String Contains a Value
 
Thanks Tom - this worked perfectly

"Tom Ogilvy" wrote:

if instr(1,cell.Value,"ABC",vbTextcompare) then
cell.EntireRow.Delete
end if

--
Regards,
Tom Ogilvy


"Lynn" wrote:

I would like a certain action to be carried out if a specified string is
found anywhere within the active cell. What code can I use to evaluate the
condition?

Eg if Customer is found anywhere in the active cell, I want to delete the
current row.



All times are GMT +1. The time now is 12:54 AM.

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