Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
this piece of code give a wrong answer ? Test Dec 05 SFE NSW Base if Strcomp(Test,"Feb") = true then ? "True" Else ? "Not" True if Strcomp(Test,"ASX") = true then ? "True" Else ? "Not" Not The word 'Feb' is not in the string but it returns a true answer. If you try the word 'ASX' it returns false. WHY and how do you fix it Thanks MarkS |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello MarkS,
StrComp does not returns boolean. Try Code: -------------------- Debug.Print StrComp(Test, "Feb") -------------------- The above code returns -1, True stands for -1 then printed "True". In this case I would suggest you InStr function instead of StrComp function as follows. Code: -------------------- If InStr(Test, "Feb") 0 Then Debug.Print "True" Else Debug.Print "Not" End If -------------------- --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Searching for a string of text inside a column | Excel Worksheet Functions | |||
Find String in another string - only between spaces | Excel Worksheet Functions | |||
Find Many String options in ONE String | Excel Worksheet Functions | |||
Check if a String is inside an Array | Excel Programming | |||
Check if a String is inside an Array | Excel Programming |