Passing an argument to a quote

Z

Zach

I have 140 spreadheets a1-a140.
I am interested in performing a task on each of them. I created a
macro that performs the task on 1 spreadheet.

I now would like to put this task in a For Next loop and be able to
make the counter run between 1-140

Here is a snippet:

For i = Startval To EndVal

Workbooks.Open Filename:= _
"M:\My Documents\Projects\a1.xls"
Rows("1:1").Select
Selection.Delete Shift:=xlUp


My question: what is the appropriate syntax to change a1.xls to
a(i).xls so my spreadheet name will change automatically to a1-a140?

Thanks for your help
Zachh
 
H

Henry

Zach,

Workbooks.Open Filename:= _
"M:\My Documents\Projects\a" & i & ".xls"

HTH
Henry
 

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