What syntex to find text

G

Guest

Hi

What I'm trying to do is:
Automate the opening of three .TXT files into Excel, format the data, moving
columns, changing fonts etc.. in each file, ready to place into a single file
to sort, filter, delete and add formulas etc.. That's the part I can handle.

Problem is the three .TXT files I receive named OUTPUT1.TXT OUTPUT2.TXT &
OUTPUT3.TXT do not always contain the same information i.e. OUTPUT1 may
contain students D.O.Birth, next time OUTPUT2 will contain D.O.Birth.
The reports are generated elsewhere so I do not have control of their
filenames. But in each the cell A2 has text indicating part of the files
content.

My problem is after opening any of the OUTPUT files, how do I check if cell
A2 contains " list with date of birth " within it's contents and if TRUE
rename the file to Output1.txt.
Also should A2 contain " list of school card " Then rename the sheet tab to
Output2.txt or should A2 contains " list of atsi students " rename the sheet
tab to Output3.txt?
What is the syntex to search/find a short string of text, say 15 char. in a
cell containing a longer 100 char string?
Can the text search/find be non_case_sensitive?

Sorry for this second post on same subject but I received a message saying
my reply to Otto Moehrbach got lost in system.

--
Thank you

Regards

Bob C
Using Windows XP Home + Office 2003 Pro
 
T

Tom Ogilvy

sStr1 =" list with date of birth "
sStr2 =" list of school card "
sStr3 =" list of atsi students "
sStr = Range("A2").Text
Select Case True
Case instr(1,sStr,sStr1,vbTextCompare) > 0
ActiveSheet.Name = "Output1.txt"
Case instr(1,sStr,sStr2,vbTextCompare) > 0
ActiveSheet.Name = "Output2.txt"
Case instr(1,sStr,sStr3,vbTextCompare) > 0
ActiveSheet.Name = "Output3.txt"
End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top