Thread
:
Check if variable contains a string
View Single Post
#
2
Posted to microsoft.public.excel.worksheet.functions
Don Guillett
external usenet poster
Posts: 10,124
Check if variable contains a string
Have a look in the vba help index for INSTR and incorporate into your IF
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Ted M H" wrote in message
...
I'm trying to write VBA code that will look at a String variable and tell
me
whether or not that String contains another String €” without erroring out.
Variable X contains this string: =SUM(AAAA,BBBB)
Variable Y contains this string: PPPP
I want something that works sort of like this:
If Variable X contains Variable Y, Then Variable W = 1
If Variable X does not contain Variable Y, Then Variable W = 2
In the example above, W will equal 2, since X does not contain Y
If Y is BBBB then W will equal 1, because X does contain Y
Many thanks.
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett