opening consecutive files

  • Thread starter Thread starter Jay Noname
  • Start date Start date
J

Jay Noname

Hi,

I've been trying to figure this out all weekend, but I'm kinda stuck. I
would like to open some text files in excel, copy some info into
another worksheet, then open another text file.

But I have to be order specific. So the first file is plate1.txt, then
open plate2.txt, and so on.
Any advice would be greatly appreciated,

jon
 
dim iCtr as long
dim myFileName as string

for ictr = 1 to 10 'whatever???
myfilename = "C:\my documents\excel\plate" & ictr & ".txt"
'your code to open and process and close
next ictr
 
you can do this in a loop

eg (untested)

dim x as integer
dim sDir as string

sDir="C:\datafiles\"

x=1
do while dir(sDir & "plate" & x & ".txt") <>""

'process file here

x=x+1
loop



Tim
 
thanks for the advice,
I'll give them a go this morning and let you know how it works out

jon
 

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

Back
Top