A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBC 'Contains' Check



 
 
Thread Tools Display Modes
  #1  
Old February 14th, 2010, 08:34 AM posted to microsoft.public.excel.worksheet.functions
msnyc07
external usenet poster
 
Posts: 97
Default VBC 'Contains' Check

Apologies gain, still trying to hack this coders VBA as a non-coder so I can
fix as he is AWOL.

Anyway part of the code was supposed to see if a cell contained specific
text but as I test it it only works on a complete match. This is the line of
code:

ElseIf InStr(UCase(CStr(wsCert.Cells(targetCertRowNumber, 1).Value)),
UCase("TEXT")) And Len(CStr(wsCert.Cells(targetCertRowNumber, 2).Value)) = 0
Then

Do I need to change something so it is finding "TEXT Anything" as right now
it is just finding "TEST"

Thanks in advance
  #2  
Old February 14th, 2010, 09:26 AM posted to microsoft.public.excel.worksheet.functions
Mike H
external usenet poster
 
Posts: 8,419
Default VBC 'Contains' Check

Hi,

Because you posted such a small snippet it's difficult to recreate you code
so here's a general example of how to construct a test with INSTR which
ignores case and finds the text within a longer string.


If InStr(1, "a bit if TEXT to test", "text", vbTextCompare) 0 Then
MsgBox "Found it"
End If
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"msnyc07" wrote:

Apologies gain, still trying to hack this coders VBA as a non-coder so I can
fix as he is AWOL.

Anyway part of the code was supposed to see if a cell contained specific
text but as I test it it only works on a complete match. This is the line of
code:

ElseIf InStr(UCase(CStr(wsCert.Cells(targetCertRowNumber, 1).Value)),
UCase("TEXT")) And Len(CStr(wsCert.Cells(targetCertRowNumber, 2).Value)) = 0
Then

Do I need to change something so it is finding "TEXT Anything" as right now
it is just finding "TEST"

Thanks in advance

  #3  
Old February 14th, 2010, 03:22 PM posted to microsoft.public.excel.worksheet.functions
Don Guillett[_2_]
external usenet poster
 
Posts: 607
Default VBC 'Contains' Check

Without seeing all of it, it appears that the test for instr is missing the
0


ElseIf InStr(UCase(CStr(wsCert.Cells(targetCertRowNumber, 1).Value)),
UCase("TEXT"))
0

And Len(CStr(wsCert.Cells(targetCertRowNumber, 2).Value)) = 0
Then


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"msnyc07" wrote in message
...
Apologies gain, still trying to hack this coders VBA as a non-coder so I
can
fix as he is AWOL.

Anyway part of the code was supposed to see if a cell contained specific
text but as I test it it only works on a complete match. This is the line
of
code:

ElseIf InStr(UCase(CStr(wsCert.Cells(targetCertRowNumber, 1).Value)),
UCase("TEXT")) And Len(CStr(wsCert.Cells(targetCertRowNumber, 2).Value)) =
0
Then

Do I need to change something so it is finding "TEXT Anything" as right
now
it is just finding "TEST"

Thanks in advance


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.