ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   check to see if cell contains a string = to member of list (https://www.excelbanter.com/excel-programming/296977-check-see-if-cell-contains-string-%3D-member-list.html)

NikkoW

check to see if cell contains a string = to member of list
 
I can't seem to find a reference to doing this. Perhaps someone could help
me.

I have a customer list that includes educational institutions. The name may
include the word "school" or "college" or "university" and a bunch of
others. I am using a macro to copy my customer list from one worksheet to
the next. If the cell containing the names of the customers (column A)
includes one of the above strings, I want to skip on to the next row and not
copy that row.

My initial thought was that there might be some function to check if a cell
contained any of my words (that had been defined as part of an array,
perhaps) but I can't seem to find an efficient way of doing this.

Any suggestions?

Thanks again.



Frank Kabel

check to see if cell contains a string = to member of list
 
Hi
one way would be to combine some InStr statement with or functions.
e.g.

sub foo()
dim sname
sname=Activesheet.range("A1").value
if instr(sname, "school") or instr(sname,"college") or _
instr(sname,"university") then
msgbox "cell A1 contains one of your words"
else
'your code
end if
end sub



--
Regards
Frank Kabel
Frankfurt, Germany


NikkoW wrote:
I can't seem to find a reference to doing this. Perhaps someone could
help me.

I have a customer list that includes educational institutions. The
name may include the word "school" or "college" or "university" and a
bunch of others. I am using a macro to copy my customer list from one
worksheet to the next. If the cell containing the names of the
customers (column A) includes one of the above strings, I want to
skip on to the next row and not copy that row.

My initial thought was that there might be some function to check if
a cell contained any of my words (that had been defined as part of an
array, perhaps) but I can't seem to find an efficient way of doing
this.

Any suggestions?

Thanks again.




All times are GMT +1. The time now is 03:42 AM.

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