Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to open a text file and read the file one line at a time. If the line
contains certain text, I want to branch and do something different. I thought this would work: If vbLine Like "pork" Then but if the vbLine is "dog,cat,pork" it fails. How do I evaluate for a portion of the vbLine variable? Other software I've used has a contains operator: vbLine!"pork" would mean does the vbLine contain "pork" vbLine!!"pork" would mean does the vbLine variable NOT contain "pork" Is there such a think in VBA? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You might try:
If Instr(1,vbLine,"Pork") Then -- Best wishes, Jim "Mike H." wrote: I want to open a text file and read the file one line at a time. If the line contains certain text, I want to branch and do something different. I thought this would work: If vbLine Like "pork" Then but if the vbLine is "dog,cat,pork" it fails. How do I evaluate for a portion of the vbLine variable? Other software I've used has a contains operator: vbLine!"pork" would mean does the vbLine contain "pork" vbLine!!"pork" would mean does the vbLine variable NOT contain "pork" Is there such a think in VBA? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Wed, 1 Aug 2007 10:32:02 -0700, Mike H.
wrote: I want to open a text file and read the file one line at a time. If the line contains certain text, I want to branch and do something different. I thought this would work: If vbLine Like "pork" Then but if the vbLine is "dog,cat,pork" it fails. How do I evaluate for a portion of the vbLine variable? Other software I've used has a contains operator: vbLine!"pork" would mean does the vbLine contain "pork" vbLine!!"pork" would mean does the vbLine variable NOT contain "pork" Is there such a think in VBA? In vba you could use the Instr function --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding the cell if text is contained within | Excel Discussion (Misc queries) | |||
Adding the cell if text is contained within | Excel Discussion (Misc queries) | |||
Sumif text is contained winthin a longer text string in a cell | Excel Worksheet Functions | |||
VLOOKUP with value contained within text | Excel Worksheet Functions | |||
Trimming text contained in cells | Excel Programming |