Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Might be a total newbie issue

  Asked By: Clifton    Date: Nov 24    Category: MS Office    Views: 831
  

..I wrote a code for copying info from a 2008 file into a 2009 file,
no problem it works just fine.

The issue is that I need to be able to run the same code for several
different files, the names are all very similar, I tried to use ? and
an * and neither worked.

If it helps the file names are "2008 ABCDE Mkt Seg Master" and "2009
Mkt Seg Master" The "ABCDE" part is what will vary on each report.

I am using Excel 2000 on my computer at home and 2002 at work...any
ideas? hints? suggestions?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Jaspreet Kapoor     Answered On: Nov 24

There are several ways of getting the job done,
but in order to decide which approach,
we'll need to discuss a bit more about your situation.
You mentioned that the "ABCDE" portion of the filename
varies for each report.
is it "predictable"? will there be more than one file
in a specific folder with different "ABCDE" values?
I use a technique like:
FName2008 = ""
Folder = "Z:\Reports\"
Set f = fso.GetFolder(Folder)
Set Files = f.Files
For Each File In Files
If ((Left(File.Name, 13) Like "2008") _
And (ucase(Right(File.Name, 18)) = "MKT SEG MASTER.XLS")) Then
FName2008 = File.Name
exit for
End If
Next File
In the past, I've used the "like" operator instead of the string
functions Left,Right,Instr:
if (Ucase(File.Name) Like "2008*MKT SEG MASTER.XLS") then
But I've gotten away from that
(it failed me once, so I tossed it aside!)
hope this helps,

 
Didn't find what you were looking for? Find more on Might be a total newbie issue Or get search suggestion and latest updates.




Tagged: